<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Kickass Labs &#187; tdd</title>
	<atom:link href="http://www.kickasslabs.com/category/tdd/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kickasslabs.com</link>
	<description>We &#9829; code.</description>
	<lastBuildDate>Sun, 04 Jul 2010 03:00:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>TDD Makes Software Go Faster</title>
		<link>http://www.kickasslabs.com/2009/08/24/tdd-makes-software-go-faster/</link>
		<comments>http://www.kickasslabs.com/2009/08/24/tdd-makes-software-go-faster/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 01:09:57 +0000</pubDate>
		<dc:creator>Brad</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[tdd]]></category>

		<guid isPermaLink="false">http://www.kickasslabs.com/?p=392</guid>
		<description><![CDATA[One of the gripes I hear about TDD is that it takes too much time.  People look at the idea of it and think, &#8220;So I have to write code and tests and update the tests when the code changes? WTF?&#8221;
My message to you is: TDD takes less time, not more.
Today&#8217;s example: I&#8217;m writing [...]]]></description>
			<content:encoded><![CDATA[<p>One of the gripes I hear about <a href="http://en.wikipedia.org/wiki/Test-driven_development" title="TDD on Wikipedia" target="tddwiki">TDD</a> is that it takes too much time.  People look at the idea of it and think, &#8220;So I have to write code <i>and</i> tests and update the tests when the code changes? WTF?&#8221;</p>
<p>My message to you is: TDD takes <i>less</i> time, not more.</p>
<p>Today&#8217;s example: I&#8217;m writing some code that uses a parsing library written by a cow-orker.  He&#8217;s a sharp guy, and the library generally works well, but it has a couple of undocumented behaviors &#8211; they&#8217;re mostly benign, and probably work for other users of the library, but for me it&#8217;s stuff that would result in misbehavior <i>way</i> up the call stack, or in another module entirely.</p>
<p>While I&#8217;m test-driving the code that uses this library, I notice the library itself does not have automated tests.  The natural-feeling thing for me to do here is to test some sample calls to the lib to make sure it does what I expect.  I know it&#8217;s not exactly canonical behavior to test outside libs that are assumed to be functioning, but it <i>is</i> good form to write tests that teach you about the system you&#8217;re building, and I needed to learn whether this library was going to parse my input in the way that I expected.  The documentation wasn&#8217;t there, I wasn&#8217;t going to figure it out by inspecting the code (which is relatively complex), so tests it was.</p>
<p>Surprise, surprise &#8211; I found out that the library did NOT behave as I expected in every case.  Had I not taken twenty minutes to write tests to introduce confidence in the parts of the system I didn&#8217;t know well, I&#8217;d probably have spent a couple hours debugging and looking in the wrong places for the problems I was having downstream.  It also led me to a relatively simple solution where I extended the library class and just overrode the elements related to my handful of problematic cases, without changing his library or breaking code that depends on it.</p>
<p>As an added bonus, not only do I know what the documentation does not tell me, but I&#8217;ll also know if and when my colleague makes changes to his library that break the expectations of <i>my</i> code.</p>
<p>So I&#8217;ve reduced debugging time, increased my confidence in my code, and protected myself against future changes.  I see it time and again &#8211; the time <i>saved</i> by writing the extra test code is well out of proportion to the time spent writing it.</p>
<p>There&#8217;s an exception here for developers or shops that are fetishistic about 100% test coverage, and do not judiciously use automated testing to learn about the system, drive design, and catch regressions.  Writing tests to cover trivial/obvious code (i.e., writing tests that do not <i>teach you about the system)</i> is a time-suck.  I&#8217;d avoid it, if I were you.</p>
<p>As long as I&#8217;m raving about TDD, I have to recommend the work of Kent Beck.  I <a href="http://twitter.com/KentBeck" title="Kent Beck on Twitter" target="kbtwitter">follow him on Twitter</a>, I <a href="http://www.threeriversinstitute.org/blog/" title="Three Rivers Institute Blog" target="kbblog">read his blog</a>, and <a href="http://www.amazon.com/gp/product/0321146530?ie=UTF8&#038;tag=kickasslabs-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0321146530" title="Test-Driven Development: By Example" target="kbbook">his book on TDD</a> changed how I write software &#8211; I count it among the indispensible books on my shelf, with the GoF Design Patterns and Knuth.  Check him out if you&#8217;re interested in deep thought about how software gets made.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.kickasslabs.com%2F2009%2F08%2F24%2Ftdd-makes-software-go-faster%2F&amp;linkname=TDD%20Makes%20Software%20Go%20Faster"><img src="http://www.kickasslabs.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.kickasslabs.com/2009/08/24/tdd-makes-software-go-faster/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
