{"id":251,"date":"2011-03-06T07:47:24","date_gmt":"2011-03-06T07:47:24","guid":{"rendered":"http:\/\/www.myfatblog.co.uk\/?p=251"},"modified":"2011-03-06T18:27:45","modified_gmt":"2011-03-06T18:27:45","slug":"spretreat-tdd-a-retrospective-see-what-i-did-there","status":"publish","type":"post","link":"http:\/\/www.myfatblog.co.uk\/index.php\/2011\/03\/spretreat-tdd-a-retrospective-see-what-i-did-there\/","title":{"rendered":"SPRetreat TDD &ndash; a retrospective (See what I did there?)"},"content":{"rendered":"<p>Not quite sure why I\u00e2\u20ac\u2122m up at 6 am on a Sunday morning writing a blog post, certainly the bed was warm and comfy, but my mind is still pretty buzzing from yesterdays SharePoint Retreat sponsored by 21Apps and Content and Code.<\/p>\n<p>What\u00e2\u20ac\u2122s SharePoint Retreat? Well it\u00e2\u20ac\u2122s a room full of geeks trying to improve the way they write code for the SharePoint platform. And it\u00e2\u20ac\u2122s fun too, we had a great time yesterday and learned a lot too. But before we talk about that, a quick thank you to Andrew Woodward and 21Apps for sponsoring food, beer and running the event and Wes Hackett of Content and Code for providing accommodation, and to TypeMock for providing a couple of prizes in the form of Licenses for their product.<\/p>\n<p>Yesterday\u00e2\u20ac\u2122s focus was TDD (Test Driven Development) and Unit Testing for SharePoint. Any of you who\u00e2\u20ac\u2122ve been around the SharePoint community know that Andrew has been an advocate of both for a long time and him and Eric Schupps have often been quite vocal in their views on the subject at many a community event. (Not to say they oppose, just differ!)<\/p>\n<p>Back at the Best Practices conference in 2009, Andrew made a prediction \u00e2\u20ac\u01532009 will be the year that developers adopt Agile and TDD\u00e2\u20ac\u009d. 1 out of 2 isn\u00e2\u20ac\u2122t bad, I think nearly everyone understands the value of Agile, but TDD just hasn\u00e2\u20ac\u2122t taken off. I think the answer to why, is the cost. Not just in the cost of the licenses to do TDD, after all we\u00e2\u20ac\u2122re in the software business and we understand that licensing is a necessary evil for what we do, after all we all want to be paid for our code. The other cost is the up front cost of TDD, there\u00e2\u20ac\u2122s the effort to learn how to do it, the cost of learning, but more importantly the cost of doing.<\/p>\n<p>I think the view I took mostly from yesterday is that if you\u00e2\u20ac\u2122re going to use TDD, you need to do it a lot, The muscle memory used to develop the test needs to become as second nature to you as changing from 2nd to 3rd in a car when the rev\u00e2\u20ac\u2122s are just right. If you don\u00e2\u20ac\u2122t do this, then you\u00e2\u20ac\u2122re going to spend more time thinking about how to do the tests, rather than what you want to achieve from the test itself.<\/p>\n<p>So is the cost worth it? Well I think yes it can be. I found even in the short space of time yesterday that as we worked on code blocks and they started to grow, we\u00e2\u20ac\u2122d change something that would break an earlier test which had to be fixed, so it get\u00e2\u20ac\u2122s you thinking about how the process of development changes as you move along the timeline. Just how many hidden bugs are you introducing as your code grows that only come about when certain conditions are met. Is testing these conditions at integration or user testing the right time to find them? Most certainly not. Spending this time up front to develop these tests as you go, does add to the development time, but SAVES time at the latter stages of the project.<\/p>\n<p>More importantly, if you (Or even someone else) has to return to the project code at a later date to add new functionality, You can see at a glance (or a quick ctrl alt T) that all the tests that exist are running fine, giving you more confidence in the code and improving readability. This means that you start on the actual work of adding the new features faster, and more importantly you can re-run those unit tests as you work, ensuring that your new features haven\u00e2\u20ac\u2122t broken the existing ones (This won\u00e2\u20ac\u2122t remove the need to test further though, so don\u00e2\u20ac\u2122t neglect the other test stages!)<\/p>\n<p>Now, as a SharePoint developer and consultant, I\u00e2\u20ac\u2122m going to put my hand up and say I don\u00e2\u20ac\u2122t use TDD and rarely if at all use unit tests, relying on manual testing and then integration and user testing at latter stages. The main reason, and possibly I\u00e2\u20ac\u2122m deluding myself here is that I tend to work on small projects, maybe a few web parts, some event handlers, a page or two and also a lot of \u00e2\u20ac\u02dcSoft\u00e2\u20ac\u2122 development i.e. xslt, branding etc. So I could probably use TDD on about 40% of my work at the moment.<\/p>\n<p>My main question would be, how do I sell the value of using TDD on a small perhaps 2 day project for a client if it\u00e2\u20ac\u2122s going to add an extra day to the cost. Certainly as the supplied I don\u00e2\u20ac\u2122t want to foot the bill for that extra day, I want to pass the cost on to the client and recoup my efforts. but if I go in quoting 50% more time than my competitor who doesn\u00e2\u20ac\u2122t use TDD, then it\u00e2\u20ac\u2122s likely I\u00e2\u20ac\u2122ll be overlooked.<\/p>\n<p>In this scenario, it\u00e2\u20ac\u2122s hard to sell the value of TDD and Unit Testing to the client. What is the likelihood that you or anyone else is going to revisit that webpart code? How long is the testing actually going to take doing it manually? BUT and this is quite a big but, IF I was to put the effort in now and absorb the cost of adding TDD to my projects now, would I recoup that cost in the future because of the improvement in my speed of production and testing and my muscle memory improves?<\/p>\n<p>I think we sometimes shy away from things that we see as a lot of effort for little return and on the face of it, TDD is possibly one of those things, but I think once you scratch the surface, the value and potential starts to show you may begin to reconsider whether the effort may in fact be worth it in the end.<\/p>\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"2\" width=\"100%\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"90%\">\n<p>So, if my retrospective has piqued your interest rather than scared you (and I hope it\u00e2\u20ac\u2122s the former!) then take a look at Andrew\u00e2\u20ac\u2122s 21Apps site where he has some great white papers on beginning unit testing. <a title=\"http:\/\/www.21apps.com\/agile\/\" href=\"http:\/\/www.21apps.com\/agile\/\">http:\/\/www.21apps.com\/agile\/<\/a> There\u00e2\u20ac\u2122s also a book recommended by Andrew that is excellent for anyone interested in starting with TDD by a chap called Roy Osherove. <\/p>\n<\/td>\n<td valign=\"top\" width=\"166\"><iframe style=\"width: 120px; height: 240px\" marginheight=\"0\" src=\"http:\/\/rcm-uk.amazon.co.uk\/e\/cm?lt1=_blank&amp;bc1=FFFFFF&amp;IS2=1&amp;nou=1&amp;bg1=FFFFFF&amp;fc1=000000&amp;lc1=0000FF&amp;t=myfabl-21&amp;o=2&amp;p=8&amp;l=as1&amp;m=amazon&amp;f=ifr&amp;asins=1933988274\" frameborder=\"0\" marginwidth=\"0\" scrolling=\"no\"><\/iframe><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>I\u00e2\u20ac\u2122m now going to go away, make a cup of tea, then sit and redo all of the exercises from yesterday and just see how much the old muscle memory kept. once that\u00e2\u20ac\u2122s done, I\u00e2\u20ac\u2122ll post it here.<\/p>\n<p><strong><em>Edit: Because of the length of time it\u00e2\u20ac\u2122s taken to do the TDD and get the screenshots, I\u00e2\u20ac\u2122ve broken the post up into a series.. Part 1 and the index is here.<\/em><\/strong><\/p>\n<p>&#160;<a title=\"Part 1 \u00e2\u20ac\u201d SharePoint Retreat\u00e2\u20ac\u201cTDD and Unit Testing, the methodology used\" href=\"http:\/\/www.myfatblog.co.uk\/?p=259\">Part 1 \u00e2\u20ac\u201d SharePoint Retreat\u00e2\u20ac\u201cTDD and Unit Testing, the methodology used<\/a><\/p>\n<p>Regards<\/p>\n<p>Paul.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Not quite sure why I\u00e2\u20ac\u2122m up at 6 am on a Sunday morning writing a blog post, certainly the bed was warm and comfy, but my mind is still pretty buzzing from yesterdays SharePoint Retreat sponsored by 21Apps and Content and Code. What\u00e2\u20ac\u2122s SharePoint Retreat? Well it\u00e2\u20ac\u2122s a room full of geeks trying to improve &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/www.myfatblog.co.uk\/index.php\/2011\/03\/spretreat-tdd-a-retrospective-see-what-i-did-there\/\">Continue reading<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[43,42,3,13,31,32,41,35],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>SPRetreat TDD &ndash; a retrospective (See what I did there?) - Blog of an overweight SharePoint addict<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.myfatblog.co.uk\/index.php\/2011\/03\/spretreat-tdd-a-retrospective-see-what-i-did-there\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SPRetreat TDD &ndash; a retrospective (See what I did there?) - Blog of an overweight SharePoint addict\" \/>\n<meta property=\"og:description\" content=\"Not quite sure why I\u00e2\u20ac\u2122m up at 6 am on a Sunday morning writing a blog post, certainly the bed was warm and comfy, but my mind is still pretty buzzing from yesterdays SharePoint Retreat sponsored by 21Apps and Content and Code. What\u00e2\u20ac\u2122s SharePoint Retreat? Well it\u00e2\u20ac\u2122s a room full of geeks trying to improve &hellip; Continue reading\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.myfatblog.co.uk\/index.php\/2011\/03\/spretreat-tdd-a-retrospective-see-what-i-did-there\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog of an overweight SharePoint addict\" \/>\n<meta property=\"article:published_time\" content=\"2011-03-06T07:47:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2011-03-06T18:27:45+00:00\" \/>\n<meta name=\"author\" content=\"Cimares\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@cimares\" \/>\n<meta name=\"twitter:site\" content=\"@cimares\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Cimares\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\/\/www.myfatblog.co.uk\/index.php\/2011\/03\/spretreat-tdd-a-retrospective-see-what-i-did-there\/\",\"url\":\"http:\/\/www.myfatblog.co.uk\/index.php\/2011\/03\/spretreat-tdd-a-retrospective-see-what-i-did-there\/\",\"name\":\"SPRetreat TDD &ndash; a retrospective (See what I did there?) - Blog of an overweight SharePoint addict\",\"isPartOf\":{\"@id\":\"http:\/\/www.myfatblog.co.uk\/#website\"},\"datePublished\":\"2011-03-06T07:47:24+00:00\",\"dateModified\":\"2011-03-06T18:27:45+00:00\",\"author\":{\"@id\":\"http:\/\/www.myfatblog.co.uk\/#\/schema\/person\/55ae8f6885bb5b8390dad001f3da83c6\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.myfatblog.co.uk\/index.php\/2011\/03\/spretreat-tdd-a-retrospective-see-what-i-did-there\/\"]}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/www.myfatblog.co.uk\/#website\",\"url\":\"http:\/\/www.myfatblog.co.uk\/\",\"name\":\"Blog of an overweight SharePoint addict\",\"description\":\"The rantings of a (not so) food obsessed IT consultant!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/www.myfatblog.co.uk\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"http:\/\/www.myfatblog.co.uk\/#\/schema\/person\/55ae8f6885bb5b8390dad001f3da83c6\",\"name\":\"Cimares\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.myfatblog.co.uk\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/www.myfatblog.co.uk\/images\/BlogImages\/About_D057\/TopOfTheWorld.jpg\",\"contentUrl\":\"http:\/\/www.myfatblog.co.uk\/images\/BlogImages\/About_D057\/TopOfTheWorld.jpg\",\"caption\":\"Cimares\"},\"sameAs\":[\"http:\/\/www.myfatblog.co.uk\"],\"url\":\"http:\/\/www.myfatblog.co.uk\/index.php\/author\/reginald\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SPRetreat TDD &ndash; a retrospective (See what I did there?) - Blog of an overweight SharePoint addict","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/www.myfatblog.co.uk\/index.php\/2011\/03\/spretreat-tdd-a-retrospective-see-what-i-did-there\/","og_locale":"en_US","og_type":"article","og_title":"SPRetreat TDD &ndash; a retrospective (See what I did there?) - Blog of an overweight SharePoint addict","og_description":"Not quite sure why I\u00e2\u20ac\u2122m up at 6 am on a Sunday morning writing a blog post, certainly the bed was warm and comfy, but my mind is still pretty buzzing from yesterdays SharePoint Retreat sponsored by 21Apps and Content and Code. What\u00e2\u20ac\u2122s SharePoint Retreat? Well it\u00e2\u20ac\u2122s a room full of geeks trying to improve &hellip; Continue reading","og_url":"http:\/\/www.myfatblog.co.uk\/index.php\/2011\/03\/spretreat-tdd-a-retrospective-see-what-i-did-there\/","og_site_name":"Blog of an overweight SharePoint addict","article_published_time":"2011-03-06T07:47:24+00:00","article_modified_time":"2011-03-06T18:27:45+00:00","author":"Cimares","twitter_card":"summary_large_image","twitter_creator":"@cimares","twitter_site":"@cimares","twitter_misc":{"Written by":"Cimares","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/www.myfatblog.co.uk\/index.php\/2011\/03\/spretreat-tdd-a-retrospective-see-what-i-did-there\/","url":"http:\/\/www.myfatblog.co.uk\/index.php\/2011\/03\/spretreat-tdd-a-retrospective-see-what-i-did-there\/","name":"SPRetreat TDD &ndash; a retrospective (See what I did there?) - Blog of an overweight SharePoint addict","isPartOf":{"@id":"http:\/\/www.myfatblog.co.uk\/#website"},"datePublished":"2011-03-06T07:47:24+00:00","dateModified":"2011-03-06T18:27:45+00:00","author":{"@id":"http:\/\/www.myfatblog.co.uk\/#\/schema\/person\/55ae8f6885bb5b8390dad001f3da83c6"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.myfatblog.co.uk\/index.php\/2011\/03\/spretreat-tdd-a-retrospective-see-what-i-did-there\/"]}]},{"@type":"WebSite","@id":"http:\/\/www.myfatblog.co.uk\/#website","url":"http:\/\/www.myfatblog.co.uk\/","name":"Blog of an overweight SharePoint addict","description":"The rantings of a (not so) food obsessed IT consultant!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.myfatblog.co.uk\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"http:\/\/www.myfatblog.co.uk\/#\/schema\/person\/55ae8f6885bb5b8390dad001f3da83c6","name":"Cimares","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.myfatblog.co.uk\/#\/schema\/person\/image\/","url":"http:\/\/www.myfatblog.co.uk\/images\/BlogImages\/About_D057\/TopOfTheWorld.jpg","contentUrl":"http:\/\/www.myfatblog.co.uk\/images\/BlogImages\/About_D057\/TopOfTheWorld.jpg","caption":"Cimares"},"sameAs":["http:\/\/www.myfatblog.co.uk"],"url":"http:\/\/www.myfatblog.co.uk\/index.php\/author\/reginald\/"}]}},"_links":{"self":[{"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/251"}],"collection":[{"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/comments?post=251"}],"version-history":[{"count":8,"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/251\/revisions"}],"predecessor-version":[{"id":263,"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/251\/revisions\/263"}],"wp:attachment":[{"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/media?parent=251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/categories?post=251"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/tags?post=251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}