<?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>Floehopper: Prefer Tests Over Comments</title>
    <link>http://blog.floehopper.org/articles/2007/05/10/prefer-tests-over-comments</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>thoughts on the bergy bits of life</description>
    <item>
      <title>Prefer Tests Over Comments</title>
      <description>&lt;p&gt;One small a-ha moment in my early programming days was when someone suggested it was better to write a comment explaining why a chunk of code worked the way it did, rather than simply describing how it worked &amp;#8211; essentially a direct translation of the code into english sentences.&lt;/p&gt;


	&lt;p&gt;Since then I&amp;#8217;ve become a &lt;a href="http://junit.sourceforge.net/doc/testinfected/testing.htm"&gt;test-infected&lt;/a&gt;, &lt;a href="http://www.amazon.co.uk/Test-Driven-Development-Addison-Wesley-Signature/dp/0321146530"&gt;test-driven&lt;/a&gt; developer and now I would always choose to write a test in preference to writing a comment. But I think the same lesson still applies&amp;#8230;&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;ve recently been making a conscious effort to come up with better test names. The easy option is for the test name to reflect what happens in the test. But it makes the test much more valuable if you can use the test name to explain why the behaviour is the way it is.&lt;/p&gt;


	&lt;p&gt;Comments are also often used as to-do items, but I think tests can be a better solution. For example, Ben mentions &lt;a href="http://www.reevoo.com/blogs/bengriffiths/2007/02/14/leaving-notes-for-the-team-in-tests/"&gt;leaving notes for the team in tests&lt;/a&gt;.&lt;/p&gt;</description>
      <pubDate>Thu, 10 May 2007 15:29:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:9c484bf4-6cae-45d2-9ab5-c64a5bd156e0</guid>
      <author>James Mead</author>
      <link>http://blog.floehopper.org/articles/2007/05/10/prefer-tests-over-comments</link>
      <category>test</category>
      <category>comment</category>
      <category>todo</category>
      <category>intent</category>
    </item>
    <item>
      <title>"Prefer Tests Over Comments" by John</title>
      <description>&lt;p&gt;Bravo! It is always better to leave the explanation of your code in a location way out of the way. I mean, having it right above the method would just clutter the mind-boggling beauty that is the sacred code.&lt;/p&gt;


	&lt;p&gt;Also, why allow non-initiates to read your code&amp;#8217;s comments to make sense of what it is doing. If someone wants to know what it is doing, well they better be ready to learn that JOY that is the language the YOU chose to develop in.&lt;/p&gt;


	&lt;p&gt;I got two words for you: Knuth+Literate Programming (okay maybe three words)&lt;/p&gt;


	&lt;p&gt;but you see, you are smarter than Knuth, because you follow the latest FAD, while he is just some old fart who talks about like stuff which is like hard and stuff.&lt;/p&gt;</description>
      <pubDate>Fri, 11 May 2007 10:16:04 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:9617afa1-310d-4688-856b-782e5f4e89ac</guid>
      <link>http://blog.floehopper.org/articles/2007/05/10/prefer-tests-over-comments#comment-262</link>
    </item>
  </channel>
</rss>
