{"id":20,"date":"2004-07-14T23:28:35","date_gmt":"2004-07-14T21:41:48","guid":{"rendered":"http:\/\/www.craigmurphy.com\/blog\/?p=20"},"modified":"2004-07-14T23:55:39","modified_gmt":"2004-07-14T22:55:39","slug":"doing-the-simplest-thing","status":"publish","type":"post","link":"http:\/\/www.craigmurphy.com\/blog\/?p=20","title":{"rendered":"Doing &#8220;the simplest thing&#8221;"},"content":{"rendered":"<p>I re-ran my <a href=\"http:\/\/www.craigmurphy.com\/bug\/index.php\">An Introduction to Test-Driven Development<\/a> session yesterday&#8230;to an exceptionally interactive and responsive audience.   The slides are free to download <a href=\"http:\/\/www.craigmurphy.com\/bug\/tdd\/13Jul2004\/TDDIntro.zip\">here<\/a> (1134k).<\/p>\n<p>I was using <a href=\"http:\/\/dunit.sourceforge.net\/\">DUnit<\/a> with Delphi 7.   I re-iterated the fact that eXtreme Programming and TDD extol the virtues of &#8220;doing the simplest thing that could possibly work&#8221;.  <\/p>\n<p>About half way through my session (which could easily have run on to 2 hours had dinner not got in the way!) a well-respected friend, <a href=\"http:\/\/www.squidsoftware.co.uk\/index.html\">Adrian<\/a>, raised his hand and said: &#8220;Building a class isn&#8217;t the simplest thing!&#8221;   <\/p>\n<p>I had built a class that converts integers into Roman numerals.  The first step was to add a method, toRoman, that took an integer and returned nothing.  The second step was to have it return &#8216;I&#8217; when &#8216;1&#8217; was passed in as a parameter.  Feel free to download the <a href=\"http:\/\/www.craigmurphy.com\/bug\/tdd\/code_tdd.zip\">Delphi 5-7<\/a> code, the <a href=\"http:\/\/www.thedelphimagazine.com\/disks\/dmag104.zip\">Delphi 8<\/a> code or the <a href=\"http:\/\/www.craigmurphy.com\/vbug\/tdd_v_code.zip\">Visual Basic.net<\/a> code.<\/p>\n<p>Of course, he was right, building a class that has one method returning the letter &#8216;I&#8217; is overkill.  It&#8217;s not the simplest thing.  Everybody knows that the simplest thing would have been a simple function with no class wrapper and no hint of object-orientation.<\/p>\n<p>I realised that what I had done was the simplest thing the could possibly work <em>in this xUnit testing framework<\/em>.  It wasn&#8217;t the simplest thing that might get the job done.<\/p>\n<p>Similarly, in an earlier re-run of the same session, <a href=\"http:\/\/www.twelve71.com\/andy\/\">Andy<\/a>, pointed out that <em>my<\/em> idea of the simplest thing perhaps wasn&#8217;t his.  And herein lies one of TDD&#8217;s ironic facets: <strong>whilst TDD provides us with a great understanding of &#8220;how&#8221; a piece of code should be invoked, thus increasing the chance that somebody other than the original developer\/programmer will be able to understand it, TDD can be an emotive process<\/strong>.  <\/p>\n<p>TDD will help you as far as your &#8220;under the bus count&#8221; goes, it will give you the most accurate form of documentation that you&#8217;ll ever have for your code base, but it won&#8217;t help you ring fence or blinker your programmers in to writing code the in the same way.  But, since that&#8217;s not something any of us should relish, Borg-like programmers churning out the identical code for the same problem, it shouldn&#8217;t put you off TDD.  <\/p>\n<blockquote><p>I&#8217;ve just googled <strong>under the bus count<\/strong> only to realise that it&#8217;s not defined anywhere.<\/p>\n<p>I&#8217;m using the phrase to mean: <\/p>\n<ul>\nthe number of people on a project who need to be run over by a bus, that will then make the project fail or incur a severe cost\/time delay<\/ul>\n<p>   If you are on a project with a team of one: yourself, then the under the bus count is one.  If one person, you, is run over by a bus, the project fails, or meets almost insurmountable cost\/delays.  Of course, if it&#8217;s just you on the project team, you probably don&#8217;t need to worry about who&#8217;s going to be picking up the project after you&#8217;re gone! <\/p>\n<p>Ideally, you should try to drive your under the bus count upwards, away from one.  There should be no single point of failure, no empire-builders.<\/p><\/blockquote>\n<p>Go practice TDD, trust me, it works.  It heralds a new confidence that will allow you to improve (refactor) huge chunks of your code base that you&#8217;d probably never want to touch citing &#8220;if it a&#8217;int broke don&#8217;t touch\/fix it&#8221;&#8230;when you know perfectly well that the internal design is like a house of cards and won&#8217;t survive the next bout of customer change requests.   It improves the quality of your life&#8230;there, what else goes this far?<\/p>\n<p>Want to learn more about TDD?  These books are highly recommended:<\/p>\n<p><a href=\"http:\/\/www.amazon.co.uk\/exec\/obidos\/ASIN\/0735619484\/craigmurphyco-21\"><img decoding=\"async\" src=\"http:\/\/www.craigmurphy.com\/images\/0735619484.01.MZZZZZZZ.jpg\" border=\"0\" alt=\"Test-Driven Development in Microsoft .net\" hspace=\"3\" vspace=\"3\" \/><\/a><br \/>\n               <a href=\"http:\/\/www.amazon.co.uk\/exec\/obidos\/ASIN\/0131016490\/craigmurphyco-21\"><img decoding=\"async\" src=\"http:\/\/www.craigmurphy.com\/images\/0131016490.02.MZZZZZZZ.jpg\" border=\"0\" alt=\"Test-Driven Development: a practical guide\" hspace=\"3\" vspace=\"3\" \/><\/a><\/p>\n<p>Test-Driven Development: a practical guide: <a href =\"http:\/\/www.craigmurphy.com\/bug\/tdd\/review.php\">Reviewed here.<\/a><\/p>\n<p>                 <a href=\"http:\/\/www.amazon.co.uk\/exec\/obidos\/ASIN\/0321146530\/craigmurphyco-21\"><img decoding=\"async\" src=\"http:\/\/www.craigmurphy.com\/images\/0321146530.02.MZZZZZZZ.jpg\" border=\"0\" alt=\"Test-Driven Development by example\" hspace=\"3\" vspace=\"3\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Your xUnit testing framework probably forces you into its modus operandi &#8211; you won&#8217;t be doing thee simplest thing possible.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,6],"tags":[],"class_list":["post-20","post","type-post","status-publish","format-standard","hentry","category-development","category-tdd"],"_links":{"self":[{"href":"http:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/20","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=20"}],"version-history":[{"count":0,"href":"http:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/20\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=20"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=20"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.craigmurphy.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=20"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}