<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Object Mentor Blog: The Quality of TDD</title>
    <link>http://blog.objectmentor.com/articles/2008/02/16/the-quality-of-tdd</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>The Quality of TDD</title>
      <description>&lt;p&gt;Kieth Braithwaite has made an interesting observation &lt;a href="http://peripateticaxiom.blogspot.com/2006/05/complexity-and-test-first-0.html"&gt;here.&lt;/a&gt;  The basic idea is that code that has been written with &lt;span class="caps"&gt;TDD&lt;/span&gt; has a lower Cyclomatic Complexity per function compared to code that has not been written with &lt;span class="caps"&gt;TDD&lt;/span&gt;.  If this is true then it could imply lower defects because of &lt;a href="http://www.enerjy.com/blog/?p=241"&gt;this.&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;Kieth&amp;#8217;s metric takes in the code for an entire project and boils it down to a single number.  His hypothesis is that a system written with &lt;span class="caps"&gt;TDD&lt;/span&gt; will always measure above a certain threshold, indicating very low CC; whereas systems written without &lt;span class="caps"&gt;TDD&lt;/span&gt; may or may not measure above that threshold.&lt;/p&gt;


	&lt;p&gt;Kieth has built a tool that you can get &lt;a href="http://www.keithbraithwaite.demon.co.uk/professional/software/measure/measure0.1.zip"&gt;here&lt;/a&gt; that will generate this metric for most java projects.  He and others have used this tool to measure many different systems.  So far the hypothesis seems to hold water.&lt;/p&gt;


	&lt;p&gt;The metric can&amp;#8217;t tell you if &lt;span class="caps"&gt;TDD&lt;/span&gt; was used; but it might just be able to tell you that it &lt;em&gt;wasn&amp;#8217;t used&lt;/em&gt;.&lt;/p&gt;</description>
      <pubDate>Sat, 16 Feb 2008 20:23:44 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:f69b083c-7868-4d59-84e6-b9185d82f7b8</guid>
      <author>Uncle Bob</author>
      <link>http://blog.objectmentor.com/articles/2008/02/16/the-quality-of-tdd</link>
      <category>Uncle Bob's Blatherings</category>
      <category>Agile Methods</category>
    </item>
    <item>
      <title>"The Quality of TDD" by Keith</title>
      <description>&lt;p&gt;By the way, Bob&amp;#8217;s link has rotted and a new version of the tool is available form &lt;a href="http://www.keithbraithwaite.demon.co.uk/professional/software/#measure" rel="nofollow"&gt;http://www.keithbraithwaite.demon.co.uk/professional/software/#measure&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Wed, 12 Mar 2008 03:26:07 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:a7c91189-c883-4f47-bd1d-c0aa436ed61c</guid>
      <link>http://blog.objectmentor.com/articles/2008/02/16/the-quality-of-tdd#comment-1653</link>
    </item>
    <item>
      <title>"The Quality of TDD" by Keith</title>
      <description>&lt;p&gt;@Mark: is there any chance of the enrjy results being written up in a more transparent style? I had actually missed the point that Christoph points out, that what that chart measures isn&amp;#8217;t quite Cyclomatic Complexity. I actually didn&amp;#8217;t find it easy to tell from the blog posting (and even more so the paper) exactly what it is that was being measured.&lt;/p&gt;


	&lt;p&gt;@bob: high CC methods doing problem-free, easy to understand, easy to test dispatching or marshaling tasks occur in more than one of the codebases I&amp;#8217;ve looked at&amp;#8212;they are a nice example of how any metric can be misleading if not interpreted properly.&lt;/p&gt;</description>
      <pubDate>Mon, 03 Mar 2008 17:08:39 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:63942ab8-e5b4-4b52-a21c-7b7c5e783934</guid>
      <link>http://blog.objectmentor.com/articles/2008/02/16/the-quality-of-tdd#comment-1628</link>
    </item>
    <item>
      <title>"The Quality of TDD" by unclebob</title>
      <description>&lt;blockquote&gt;
		&lt;p&gt;@Bob: Why not replace the switch statement with a Map?&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;Could do.  But why?  In this case the switch statement is simple, expressive, and terse.&lt;/p&gt;</description>
      <pubDate>Sun, 24 Feb 2008 09:07:36 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:44eb2a53-a05b-438f-87a0-bf5a372a1a78</guid>
      <link>http://blog.objectmentor.com/articles/2008/02/16/the-quality-of-tdd#comment-1615</link>
    </item>
    <item>
      <title>"The Quality of TDD" by Leandro Zis</title>
      <description>&lt;p&gt;@Bob: Why not replace the switch statement with a Map?&lt;/p&gt;</description>
      <pubDate>Sat, 23 Feb 2008 14:13:49 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:5c90da7a-322a-4a10-b126-b325c884029d</guid>
      <link>http://blog.objectmentor.com/articles/2008/02/16/the-quality-of-tdd#comment-1614</link>
    </item>
    <item>
      <title>"The Quality of TDD" by Christoph Beck</title>
      <description>&lt;p&gt;If Rich&amp;#8217;s data is on a per file basis, it&amp;#8217;s not CC (and shouldn&amp;#8217;t be named CC). Rather it comes close to another metric called WMC or &amp;#8220;Weighted Methods per Class&amp;#8221;, which sums up CC values of a class. For a file based CC metric, it might have been better to take the maximum, but that way, the data presented is not that useful.&lt;/p&gt;


	&lt;p&gt;@Keith: Now, where does the magic minimum at 11 come from? Let me guess: in a typical code base we have a relevant amount of trivial, bean-like classes, usually without bugs. If we were looking at the distribution of the number of properties of these bean classes, we might find a maximum at around 5 or 6. Now each property has a getter and a setter with CC of 1, which results in a higher number of bean classes whose CC values sum up to something around 11. I&amp;#8217;m pretty sure the function would be monotone increasing if these classes would have been excluded.&lt;/p&gt;


	&lt;p&gt;@Bob: I just analyzed fitnesse with &lt;a href="http://stan4j.com" rel="nofollow"&gt;STAN&lt;/a&gt;. You are right, the project has low CC values. However, to be nasty too, there are around 10 classes in the fitnesse tree with WMC &amp;gt; 38. According to Rich, these classes have &amp;gt; 50% probability of being fault-prone.&lt;/p&gt;</description>
      <pubDate>Wed, 20 Feb 2008 11:14:43 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:efdf1976-7cdc-4a90-b7a0-8611fd8db94c</guid>
      <link>http://blog.objectmentor.com/articles/2008/02/16/the-quality-of-tdd#comment-1610</link>
    </item>
    <item>
      <title>"The Quality of TDD" by unclebob</title>
      <description>Mark Dixon said:
	&lt;blockquote&gt;
		&lt;p&gt;Another useful approach would be to create a static analysis rule that fires whenever a method has complexity over a certain threshold and then use the number of firings as a predictor. We had a hard time coming up with a threshold that worked well for real-world code, though. Values below around 20 seemed to fire very often and on code that, to our mind, didn&#226;&#8364;&#8482;t need refactoring. Values above 20 just seemed pointless :-)&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;Well, just to be nasty, let me point out that in all 45,000 lines of FitNesse there is only one function with a CC &amp;gt; 20.  It happens to be a big switch statement that translates http error codes into strings.  e.g. 404-&amp;gt;&amp;#8221;Not Found&amp;#8221;.&lt;/p&gt;</description>
      <pubDate>Wed, 20 Feb 2008 09:05:45 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:8452d9dc-7c26-477c-bc4d-a80862801acb</guid>
      <link>http://blog.objectmentor.com/articles/2008/02/16/the-quality-of-tdd#comment-1608</link>
    </item>
    <item>
      <title>"The Quality of TDD" by Mark Dixon</title>
      <description>&lt;p&gt;I just wanted to follow up to the point about Rich&amp;#8217;s data showing low probabilities for surprisingly high complexity values.&lt;/p&gt;


	&lt;p&gt;The Enerjy data is calculated entirely at the file level, so you can&amp;#8217;t compare the Enerjy numbers with the traditional 7-10 range that applies at method level. This comes back to one of the fundamental problems with CC these days &amp;#8211; most metrics are measured at a file level but CC only makes sense at the method level. Averaging the CC over the file makes no sense as the whole point of it is to highlight methods with unusual values. For Enerjy we decided to just sum the CC of all methods in the file to get a file-level metric.&lt;/p&gt;


	&lt;p&gt;Another useful approach would be to create a static analysis rule that fires whenever a method has complexity over a certain threshold and then use the number of firings as a predictor. We had a hard time coming up with a threshold that worked well for real-world code, though. Values below around 20 seemed to fire very often and on code that, to our mind, didn&amp;#8217;t need refactoring. Values above 20 just seemed pointless :-)&lt;/p&gt;


	&lt;p&gt;Mark&lt;/p&gt;</description>
      <pubDate>Tue, 19 Feb 2008 17:10:11 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:6bec8c71-8249-433b-b498-a7254cd3eb49</guid>
      <link>http://blog.objectmentor.com/articles/2008/02/16/the-quality-of-tdd#comment-1603</link>
    </item>
    <item>
      <title>"The Quality of TDD" by Paddy Healey</title>
      <description>&lt;p&gt;Another tool that I think could be interesting is Crap4j: &lt;a href="http://www.crap4j.org" rel="nofollow"&gt;http://www.crap4j.org&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Tue, 19 Feb 2008 14:50:02 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:8c5be287-c406-4852-a2fc-a2e761c01f2f</guid>
      <link>http://blog.objectmentor.com/articles/2008/02/16/the-quality-of-tdd#comment-1602</link>
    </item>
    <item>
      <title>"The Quality of TDD" by www.jamesladdcode.com</title>
      <description>&lt;p&gt;This is a great tool for measuring complexity in Java code:
&lt;a href="http://www.martyandrews.net/resources/complexian.html" rel="nofollow"&gt;http://www.martyandrews.net/resources/complexian.html&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Sun, 17 Feb 2008 14:55:48 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:1c27f048-1c4b-4a2d-a286-6dd87a785a0c</guid>
      <link>http://blog.objectmentor.com/articles/2008/02/16/the-quality-of-tdd#comment-1595</link>
    </item>
    <item>
      <title>"The Quality of TDD" by Keith</title>
      <description>&lt;p&gt;Hi Bob, 
Actually, its not so simple as that TDD code has less complexity per method absolutely (if only), but rather that there is a &lt;em&gt;preference&lt;/em&gt; for more simple methods in TDD code.&lt;/p&gt;


	&lt;p&gt;What fascinates me about Rich&amp;#8217;s data is that the minimum probability of defects comes at what might be considered quite a high complexity.&lt;/p&gt;


	&lt;p&gt;By the way, I&amp;#8217;m working on a new version of the tool with some visualization features that makes the differences in codebases a little easier to grasp. Should be available sometime in the next couple of weeks.&lt;/p&gt;


	&lt;p&gt;Keith&lt;/p&gt;


	&lt;p&gt;(PS, the rule is &amp;#8220;i before e, except when it&amp;#8217;s not&amp;#8221; ;)&lt;/p&gt;</description>
      <pubDate>Sun, 17 Feb 2008 11:27:40 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:29624557-a102-461f-83e2-3fc25da21dc6</guid>
      <link>http://blog.objectmentor.com/articles/2008/02/16/the-quality-of-tdd#comment-1593</link>
    </item>
    <item>
      <title>"The Quality of TDD" by Alicia</title>
      <description>&lt;p&gt;Braithwaite is a genius. Im sure this will work perfectly.&lt;/p&gt;</description>
      <pubDate>Sun, 17 Feb 2008 08:49:02 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:5972a605-a343-4c11-b67e-772bd630d92e</guid>
      <link>http://blog.objectmentor.com/articles/2008/02/16/the-quality-of-tdd#comment-1592</link>
    </item>
  </channel>
</rss>
