<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5264980717732458077</id><updated>2011-07-30T14:36:42.184-07:00</updated><category term='Legacy code'/><category term='Unit tests'/><category term='TDD'/><category term='Agile'/><category term='Failing test'/><category term='test suite'/><category term='bug'/><category term='Scrum'/><title type='text'>Practical TDD</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://tddtrainingcourse.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5264980717732458077/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://tddtrainingcourse.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>TDD Training Course</name><uri>http://www.blogger.com/profile/15717215819587920456</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DJnslHefsmc/SrS3QClzvhI/AAAAAAAAAAg/O3vWRkbNfSA/S220/TDDGreen.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>8</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5264980717732458077.post-1907861702733466868</id><published>2009-11-19T10:06:00.000-08:00</published><updated>2009-11-19T10:08:41.196-08:00</updated><title type='text'>Sad to watch non TDD project</title><content type='html'>&lt;span style="font-family: arial;"&gt;First a bit of my background. I am a Contractor in the UK. I generally work for large corporate companies, for 3 to 9 months. Over the past 4 years I have been fortunate enough to work in mainly Agile environments and at the very least been able to use TDD and spread the word about TDD.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;Due to the recent Credit Crunch (2009) I have had to take a short contract in a non-agile, non TDD environment. There are about 60 Developers, 10 Business Analysts and some Testers. There appears to be about 3 major projects at various stages. I am closely linked to one of the projects.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;The ‘progress’ of the project is so sad to watch.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;How can you work on an application that does not have a set of run-able tests? (Either a side product of using TDD or some ‘test after’ technique).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;How, is it possible to have any confidence in an application that is not fully built and integrated until some deadline approaches?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;How, and why would anyone not exercise code until it is released into a test environment? Is it a surprise that bugs are found?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;People often say there is an overhead in doing TDD, DUH, that’s right TDDers are doing design work and ensuring that only virtually bug free code is released.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;Actually there are some huge overheads in a non TDD project. One in particular is where a new Developer is introduced to the Team to try and hit some imaginary deadline. The newbie has no chance of understanding the code in such a short time, yet is pressurized to get the work done.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;With TDD, a Team Leader can just point the newbie at a group of tests, and in a few hours they will have a firm understanding of the area of code that they will be working in. Not only that, the existing tests will quickly let the newbie know if they are doing the right thing.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;Watching a non TDD project is really, really sad. The deadline approaches, more Developers are enrolled into the team. This slows things down. Project Managers are fired, tempers flare, pressure is high, and you still need to produce some working code.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;At the very least, using TDD would prevent the bug bounce that I see on this project. 90 bugs two weeks ago, 20 fixed, 25 new bugs reported!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;It’s a real shame that people still try and build applications in a way that seems doomed. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;Sad, sad, sad. &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;Help I am a TDDer get me out of here!&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;Oh before you ask, yes I will try and surreptitiously introduce TDD to a couple of people I work with.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5264980717732458077-1907861702733466868?l=tddtrainingcourse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tddtrainingcourse.blogspot.com/feeds/1907861702733466868/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tddtrainingcourse.blogspot.com/2009/11/sad-to-watch-non-tdd-project.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5264980717732458077/posts/default/1907861702733466868'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5264980717732458077/posts/default/1907861702733466868'/><link rel='alternate' type='text/html' href='http://tddtrainingcourse.blogspot.com/2009/11/sad-to-watch-non-tdd-project.html' title='Sad to watch non TDD project'/><author><name>TDD Training Course</name><uri>http://www.blogger.com/profile/15717215819587920456</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DJnslHefsmc/SrS3QClzvhI/AAAAAAAAAAg/O3vWRkbNfSA/S220/TDDGreen.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5264980717732458077.post-3078249515939605153</id><published>2009-09-27T02:15:00.000-07:00</published><updated>2009-12-22T23:36:43.807-08:00</updated><title type='text'>What are people saying about TDD?</title><content type='html'>Here are some of the positive things that people are saying about Test Driven Development.&lt;br /&gt;&lt;br /&gt;&lt;div class="TwitterReTweetForTDDBlog"&gt;Said by &lt;a href="http://twitter.com/potatoihave/" target="_blank"&gt;potatoihave&lt;/a&gt; on Twitter.&lt;br /&gt;&lt;br /&gt;     Huge payback today as I made big changes to a library, and my tests saved me from surprise after surprise.  &lt;br /&gt; &lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="TwitterReTweetForTDDBlog"&gt;Said by &lt;a href="http://twitter.com/panesofglass" target="_blank"&gt;panesofglass &lt;/a&gt; on Twitter.&lt;br /&gt;&lt;br /&gt;I think I'm finally really getting #tdd, and I can't imagine how people want to war against it. It makes coding so flipping easy.&lt;br /&gt; &lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="TwitterReTweetForTDDBlog"&gt;Said by &lt;a href="http://twitter.com/runegri" target="_blank"&gt;runegri &lt;/a&gt; on Twitter.&lt;br /&gt;TDD is so incredibly nice! I just did a major refactoring of my pet project and I know for certain that I didn't break anything&lt;br /&gt; &lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="TwitterReTweetForTDDBlog"&gt;Said by &lt;a href="http://twitter.com/oliyoung" target="_blank"&gt;oliyoung &lt;/a&gt; on Twitter.&lt;br /&gt;I really don't know how you do anything like a decent webapp without TDD and a good CI framework these days&lt;br /&gt; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5264980717732458077-3078249515939605153?l=tddtrainingcourse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tddtrainingcourse.blogspot.com/feeds/3078249515939605153/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tddtrainingcourse.blogspot.com/2009/09/what-are-people-saying-about-tdd.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5264980717732458077/posts/default/3078249515939605153'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5264980717732458077/posts/default/3078249515939605153'/><link rel='alternate' type='text/html' href='http://tddtrainingcourse.blogspot.com/2009/09/what-are-people-saying-about-tdd.html' title='What are people saying about TDD?'/><author><name>TDD Training Course</name><uri>http://www.blogger.com/profile/15717215819587920456</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DJnslHefsmc/SrS3QClzvhI/AAAAAAAAAAg/O3vWRkbNfSA/S220/TDDGreen.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5264980717732458077.post-4677966588921060614</id><published>2009-09-26T00:20:00.000-07:00</published><updated>2009-09-27T11:46:33.601-07:00</updated><title type='text'>TDD Shoots Cowboy off His Speedy Horse</title><content type='html'>There is a cowboy developer\programmer, speeding through the wilderness on his horse. He can produce code faster than anyone.&lt;br /&gt;&lt;br /&gt;Give him a rough sparse user specification and he will have a working solution in a matter a days.&lt;br /&gt;&lt;br /&gt;So, if you were to enforce TDD on this cowboy, of course he will say that it slows him down. It will slow him down significantly.&lt;br /&gt;&lt;br /&gt;He has never done any design in the past, now you are asking him to design his whole application.&lt;br /&gt;&lt;br /&gt;It’ like taking him off his horse and removing his Stetson. You are trying to change him from a cowboy and on the way to being a professional. Do not expect that to be easy.&lt;br /&gt;&lt;br /&gt;Of course he will fight against it. He can produce an application in a month, whilst the same application written with TDD will take 6, 7, or eight weeks, certainly a longer period than the cowboy takes.&lt;br /&gt;&lt;br /&gt;Do not get me wrong when I say the cowboy can write an application in one month. It’s is usually an illusion.  The customer will like the look of it. The customer may even test a few of the features and say WOW. What the customer does not know, that underneath that pretty UI is a pit of snakes and scorpions just waiting to bite.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Customer:&lt;/span&gt; Can we have a feature added?&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;TDD:&lt;/span&gt;  No problem, should be ready in two days and I can prove that I have not introduced any bugs.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Cowboy:&lt;/span&gt; Dunno about that. The coding is fixed. You’ll have to be responsible for any bugs that are introduced. You really should not be introducing changes at this late stage&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Manager:&lt;/span&gt;  We’ve got a new Developer joining the team. Can you get him up to speed on the project?&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;TDD: &lt;/span&gt;Yes, the Tests serve as a ‘living’ fully up to date design document. The new Developer can quickly see the purpose of classes and methods. The new Developer will become productive in just a few hours.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Cowboy:&lt;/span&gt; I can’t really show someone how my code. (Secretly I do not know how it works myself. I’d be embarrassed to show the code to someone else.) We don’t need a new Developer. I can finish off. Just give me pizza and let me work through the night and weekends.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Team Leader:&lt;/span&gt; Change the algorithm in a method to make it more efficient.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;TDD:&lt;/span&gt; Not a problem. This is called re-factoring. We do it all the time during TDD.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Cowboy:&lt;/span&gt; Change one of my methods? Do you realise that it will have an impact on the rest of the application? This could set the project back by weeks.&lt;br /&gt;&lt;br /&gt;Oasis, thanks for your comment on 27 Sept 2009&lt;br /&gt;&lt;br /&gt;I just want clarify what I mean by refactoring.&lt;br /&gt;&lt;br /&gt;Suppose we have the following method.&lt;br /&gt;&lt;div id="readme1" class="announce"&gt;&lt;div class="plain"&gt;&lt;pre&gt;        public Price GetPrice1(List&lt;price&gt; prices, string requiredItem)&lt;br /&gt;     {&lt;br /&gt;         Price priceFound = null;&lt;br /&gt;         foreach (Price price in prices)&lt;br /&gt;         {&lt;br /&gt;             if (price.Name == requiredItem)&lt;br /&gt;             {&lt;br /&gt;                 priceFound = price;&lt;br /&gt;                 break;&lt;br /&gt;             }             &lt;br /&gt;         }&lt;br /&gt;         return priceFound;&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;&lt;/price&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;The code can be refactored in the following way.&lt;br /&gt;&lt;br /&gt;First, the method signature must NOT be altered.&lt;br /&gt;&lt;br /&gt;The code within the method can then be improved. For example a decision may have been taken to implement LINQ for objects.&lt;br /&gt;&lt;br /&gt;All the tests should still pass and have no knowledge of the fact that the method has been changed.&lt;br /&gt;&lt;br /&gt;&lt;div id="readme2" class="announce"&gt;&lt;div class="plain"&gt;&lt;pre&gt;      public Price GetPrice(List&lt;price&gt; prices, string requiredItem)&lt;br /&gt;     {&lt;br /&gt;         return (from n in prices where n.Name == requiredItem select n).SingleOrDefault();&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;&lt;/price&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5264980717732458077-4677966588921060614?l=tddtrainingcourse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tddtrainingcourse.blogspot.com/feeds/4677966588921060614/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tddtrainingcourse.blogspot.com/2009/09/tdd-shoots-cowboy-off-his-speedy-horse.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5264980717732458077/posts/default/4677966588921060614'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5264980717732458077/posts/default/4677966588921060614'/><link rel='alternate' type='text/html' href='http://tddtrainingcourse.blogspot.com/2009/09/tdd-shoots-cowboy-off-his-speedy-horse.html' title='TDD Shoots Cowboy off His Speedy Horse'/><author><name>TDD Training Course</name><uri>http://www.blogger.com/profile/15717215819587920456</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DJnslHefsmc/SrS3QClzvhI/AAAAAAAAAAg/O3vWRkbNfSA/S220/TDDGreen.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5264980717732458077.post-651579497727873535</id><published>2009-09-19T09:45:00.000-07:00</published><updated>2009-09-19T09:47:32.034-07:00</updated><title type='text'>I Enjoy TDD because ...</title><content type='html'>&lt;span style="font-family: arial;"&gt;I’d like to know why you enjoy using Test Driven Development (TDD).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;Just leave a short message about why you love TDD, how did you get converted?&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5264980717732458077-651579497727873535?l=tddtrainingcourse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tddtrainingcourse.blogspot.com/feeds/651579497727873535/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tddtrainingcourse.blogspot.com/2009/09/i-enjoy-tdd-because.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5264980717732458077/posts/default/651579497727873535'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5264980717732458077/posts/default/651579497727873535'/><link rel='alternate' type='text/html' href='http://tddtrainingcourse.blogspot.com/2009/09/i-enjoy-tdd-because.html' title='I Enjoy TDD because ...'/><author><name>TDD Training Course</name><uri>http://www.blogger.com/profile/15717215819587920456</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DJnslHefsmc/SrS3QClzvhI/AAAAAAAAAAg/O3vWRkbNfSA/S220/TDDGreen.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5264980717732458077.post-8953722393072503072</id><published>2009-09-19T03:32:00.001-07:00</published><updated>2009-09-19T03:35:27.510-07:00</updated><title type='text'>TDD We got no time for that.</title><content type='html'>&lt;span style="font-size:100%;"&gt;&lt;span style="font-family: arial;"&gt;&lt;/span&gt;&lt;span style="font-family: arial;"&gt;I have been on two projects where the Developers were instructed not to use TDD, because, “We don’t have time for that.”&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: arial;"&gt;In my head I am saying to that person, “What! You don’t have time to let me design the software that you so urgently need?”&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;I am not sure why corporate companies get into this state. Perhaps a few executives pick a random budget, say £2,000,000. &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;The processes in the corporate environment then burn up a lot of that budget. Constant meetings, planning, prioritisation, risk management, highly detailed design documents etc.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: arial;"&gt;When it gets down to doing the actual coding, there is only 5% £100,000 of the budget remaining.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;&lt;br /&gt;Of course there will then be panic. Of course a Project Manager is not going to be impressed when you say you want to increase the code production time by using TDD.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;&lt;br /&gt;It’s kind of ironic, that the rushed coding, hacking, panic, misunderstandings lead to more bugs which would have been detected with TDD.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;&lt;br /&gt;It really is sad when a project finds itself I this state.  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;&lt;br /&gt;Yes, at the Development stage TDD obviously takes longer. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;&lt;br /&gt;But you’ve got to look at the bigger picture.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family: arial;"&gt;Better quality code delivered.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family: arial;"&gt;Code that is more stable.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family: arial;"&gt;Code that is far more easy to maintain.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family: arial;"&gt;Code that can easily be enhanced with new features.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family: arial;"&gt;Far lest bug bounce between Customers, Testers and Developers.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family: arial;"&gt;Oh and a far calmer, professional working environment.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5264980717732458077-8953722393072503072?l=tddtrainingcourse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tddtrainingcourse.blogspot.com/feeds/8953722393072503072/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tddtrainingcourse.blogspot.com/2009/09/tdd-we-got-no-time-for-that.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5264980717732458077/posts/default/8953722393072503072'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5264980717732458077/posts/default/8953722393072503072'/><link rel='alternate' type='text/html' href='http://tddtrainingcourse.blogspot.com/2009/09/tdd-we-got-no-time-for-that.html' title='TDD We got no time for that.'/><author><name>TDD Training Course</name><uri>http://www.blogger.com/profile/15717215819587920456</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DJnslHefsmc/SrS3QClzvhI/AAAAAAAAAAg/O3vWRkbNfSA/S220/TDDGreen.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5264980717732458077.post-9029872367089643851</id><published>2009-09-19T02:22:00.000-07:00</published><updated>2009-09-26T10:09:38.863-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Legacy code'/><category scheme='http://www.blogger.com/atom/ns#' term='bug'/><category scheme='http://www.blogger.com/atom/ns#' term='TDD'/><title type='text'>TDD Travels Back In Time</title><content type='html'>&lt;span style=";font-family:arial;font-size:100%;"  &gt;Fixing Bugs in Legacy Code&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt;Sometimes we have to fix a bug in code that was not developed using TDD and has no tests.&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt;What I do this is to use one of the main principles of TDD and start with a failing test. &lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt;This failing test should replicate the bug report. &lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt;Then when you fix the code, the test should pass.&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt;Sometimes when looking at an ‘old’ piece of code in can be tempting just to try and fix it. &lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt;But make the effort of adding a testing framework and the first test. You and your colleagues will benefit in the long run. &lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt;The code will gradually become more stable and more maintainable.&lt;br /&gt;&lt;br /&gt;This principle can also be used when adding new functionality to an existing application that was developed without TDD.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5264980717732458077-9029872367089643851?l=tddtrainingcourse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tddtrainingcourse.blogspot.com/feeds/9029872367089643851/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tddtrainingcourse.blogspot.com/2009/09/tdd-travels-back-in-time.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5264980717732458077/posts/default/9029872367089643851'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5264980717732458077/posts/default/9029872367089643851'/><link rel='alternate' type='text/html' href='http://tddtrainingcourse.blogspot.com/2009/09/tdd-travels-back-in-time.html' title='TDD Travels Back In Time'/><author><name>TDD Training Course</name><uri>http://www.blogger.com/profile/15717215819587920456</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DJnslHefsmc/SrS3QClzvhI/AAAAAAAAAAg/O3vWRkbNfSA/S220/TDDGreen.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5264980717732458077.post-8277253736066486422</id><published>2009-09-19T00:41:00.000-07:00</published><updated>2009-09-19T02:28:09.264-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='test suite'/><category scheme='http://www.blogger.com/atom/ns#' term='Unit tests'/><category scheme='http://www.blogger.com/atom/ns#' term='TDD'/><title type='text'>TDD Spawns a Guardian Angel</title><content type='html'>&lt;span style="font-family:arial;"&gt;OK We all know that TDD is a technique for DESIGNING your code.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;One of the massive side effects of TDD is that you end up with a set of tests that should give nearly 100% coverage of your code.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;This set of tests is what I refer to as your Guardian Angel. The effects of having this set of tests constantly looking over your shoulder is immense. Especially if a project reaches a panic stage where people are introducing late changes and new requirements. Being able to run hundreds of tests before doing a build and release is immeasurable.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;The set of tests can also come to your rescue when someone says have “you got any design documentation”. Of course you have. The tests represent the most up to date design document that you can have. (Unlike separate documentation that can quickly become out of date.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;So, have you got a Guardian Angel or a little devil on your shoulder?&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5264980717732458077-8277253736066486422?l=tddtrainingcourse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tddtrainingcourse.blogspot.com/feeds/8277253736066486422/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tddtrainingcourse.blogspot.com/2009/09/tdd-spawns-guardian-angel.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5264980717732458077/posts/default/8277253736066486422'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5264980717732458077/posts/default/8277253736066486422'/><link rel='alternate' type='text/html' href='http://tddtrainingcourse.blogspot.com/2009/09/tdd-spawns-guardian-angel.html' title='TDD Spawns a Guardian Angel'/><author><name>TDD Training Course</name><uri>http://www.blogger.com/profile/15717215819587920456</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DJnslHefsmc/SrS3QClzvhI/AAAAAAAAAAg/O3vWRkbNfSA/S220/TDDGreen.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5264980717732458077.post-7491786167642528132</id><published>2009-09-18T00:05:00.000-07:00</published><updated>2009-09-18T08:44:23.177-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Failing test'/><category scheme='http://www.blogger.com/atom/ns#' term='Scrum'/><category scheme='http://www.blogger.com/atom/ns#' term='Agile'/><category scheme='http://www.blogger.com/atom/ns#' term='TDD'/><title type='text'>TDD is a complete failure.</title><content type='html'>&lt;span style=";font-family:arial;font-size:100%;"  &gt;&lt;br /&gt;What I mean by that is when you design a method using TDD, you start with a failing test, and you then implement code to make the test pass.&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt;The test defines your expectations of the code that you will be designing. When writing the test, think in terms of what a client or consumer would expect of the method.&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt;Let me demonstrate. Imagine some sort of financial accounting system. We have a list of credits, money going into the account and a list of debits, money leaving the account.&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt;For the sake of this demonstration, let's have the two sets of values in two arrays:&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt;    &lt;span style="color: rgb(0, 0, 153);"&gt;int[] credits = {23, 42, 117, 11, 48};  &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 153);font-size:100%;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 153);font-family:arial;font-size:100%;"  &gt;    int[] debits = {93, 22, 38, 29, 14};   &lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt;Our first test will look like this. (This is written in C#)&lt;/span&gt;&lt;br /&gt;&lt;div id="readme" class="announce"&gt;&lt;div class="plain"&gt;&lt;pre&gt;[TestMethod]&lt;br /&gt;public void Calculate_CreditsGreaterThanDebits()&lt;br /&gt;{&lt;br /&gt;  int[] credits = {23, 42, 117, 11, 48};  // Total: 241&lt;br /&gt;  int[] debits = {93, 22, 38, 29, 14};    // Total: 196&lt;br /&gt;  Account account = new Account();&lt;br /&gt;  int balance = account.Calculate(credits, debits);&lt;br /&gt;&lt;br /&gt;  // We expect the result to be 45, that’s (241 - 196)&lt;br /&gt;  // In TDD we can perform various checks using something called an assert.&lt;br /&gt;  // In this case, I just want to check that the balance is equal to 45.&lt;br /&gt;&lt;br /&gt;  Assert.AreEqual(45, balance);&lt;br /&gt;&lt;br /&gt;  // If the balance is anything other than 45, the test will fail.&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt;First of all our code won't compile, so add the new method Calculate with the minimum of code to enable compilation.&lt;/span&gt;&lt;br /&gt;&lt;div id="readme" class="announce"&gt;&lt;div class="plain"&gt;&lt;pre&gt;public class Account&lt;br /&gt;{&lt;br /&gt;public int Calculate(int[] credits, int[]javascript:void(0) debits)&lt;br /&gt;{&lt;br /&gt;    return 0;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt;The project will now compile. Run the test and we will get the following failure.&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 153);font-family:arial;font-size:100%;"  &gt;Assert.AreEqual failed. Expected:&lt;45&gt;. Actual:&lt;0&gt;.  &lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt;That's good news. In TDD we love a failing test. We can now do the enjoyable part of writing real code to make the test pass.&lt;/span&gt;&lt;br /&gt;&lt;div id="readme" class="announce"&gt;&lt;div class="plain"&gt;&lt;pre&gt;&lt;br /&gt;public class Account&lt;br /&gt;{&lt;br /&gt; public int Calculate(int[] credits, int[] debits)&lt;br /&gt; {&lt;br /&gt;     int totalCredit = 0;&lt;br /&gt;     int totalDebit = 0;&lt;br /&gt;&lt;br /&gt;     foreach (int credit in credits)&lt;br /&gt;         totalCredit += credit;&lt;br /&gt;&lt;br /&gt;     foreach (int debit in debits)&lt;br /&gt;         totalDebit += debit;&lt;br /&gt;&lt;br /&gt;     return totalCredit - totalDebit;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt;Run the test again and it now passes&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt;Notice the name of the test, Calculate_CreditsGreaterThanDebits.&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt;The first part, Calculate, indicates the target method that I am designing. The second part describes the scenario that I am designing for. &lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt;The name of the class that contains this test is AccountTests. This naming convention means that this test class will be used to design the methods in the Accounts class.&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:100%;"  &gt;Having got this one scenario working, you then implement a few more scenarios such as:&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 153);font-family:arial;font-size:100%;"  &gt;Calculate_CreditsLessThanDebits()&lt;/span&gt;&lt;span style="color: rgb(0, 0, 153);font-size:100%;" &gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 153);font-family:arial;font-size:100%;"  &gt;Calculate_CreditsEqualToDebits()&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5264980717732458077-7491786167642528132?l=tddtrainingcourse.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tddtrainingcourse.blogspot.com/feeds/7491786167642528132/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://tddtrainingcourse.blogspot.com/2009/09/tdd-is-complete-failure.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5264980717732458077/posts/default/7491786167642528132'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5264980717732458077/posts/default/7491786167642528132'/><link rel='alternate' type='text/html' href='http://tddtrainingcourse.blogspot.com/2009/09/tdd-is-complete-failure.html' title='TDD is a complete failure.'/><author><name>TDD Training Course</name><uri>http://www.blogger.com/profile/15717215819587920456</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://2.bp.blogspot.com/_DJnslHefsmc/SrS3QClzvhI/AAAAAAAAAAg/O3vWRkbNfSA/S220/TDDGreen.JPG'/></author><thr:total>0</thr:total></entry></feed>
