<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Harold&#8217;s Corollary to Knuth&#8217;s Law</title>
	<atom:link href="http://cafe.elharo.com/testing/harolds-corollary-to-knuths-law/feed/" rel="self" type="application/rss+xml" />
	<link>http://cafe.elharo.com/testing/harolds-corollary-to-knuths-law/</link>
	<description>Longer than a blog; shorter than a book</description>
	<pubDate>Tue, 06 Jan 2009 22:17:56 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>By: Name required</title>
		<link>http://cafe.elharo.com/testing/harolds-corollary-to-knuths-law/#comment-327633</link>
		<dc:creator>Name required</dc:creator>
		<pubDate>Mon, 22 Dec 2008 15:47:24 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/?p=246#comment-327633</guid>
		<description>&#62;  Mocks are an abomination, requiring far too much effort to build

You're doing them wrong.</description>
		<content:encoded><![CDATA[<p>&gt;  Mocks are an abomination, requiring far too much effort to build</p>
<p>You&#8217;re doing them wrong.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Freeman</title>
		<link>http://cafe.elharo.com/testing/harolds-corollary-to-knuths-law/#comment-261153</link>
		<dc:creator>Steve Freeman</dc:creator>
		<pubDate>Tue, 12 Aug 2008 20:09:37 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/?p=246#comment-261153</guid>
		<description>I'm one of the authors of the various Mock Object papers. I agree absolutely with your first two points but, being less polite than J.B., I think you've completely missed the point on the third. Your strawman description is a travesty of what TDD with Mocks should be about. It does describe a naive approach that has become too widespread, but raw critical postings like this one have the unfortunate effect of perpetuating the broken ideas.

I'd even disagree with J.B., in that mocking expensive external resources is absolutely the wrong way to introduce the ideas. The important thing is to think about how object collaborate and what services they need from their neighbours, so Joe Walnes' Novice rule is "Only mock types you own" -- that way one can concentrate on design issues not performance. 

Although some people have practised it forever, TDD is still very early in its adoption curve. Given the proportion of programmers who still struggle with OO concepts, we should be clear about when TDD practices are fundamentally broken and when they suffer from weak skills.</description>
		<content:encoded><![CDATA[<p>I&#8217;m one of the authors of the various Mock Object papers. I agree absolutely with your first two points but, being less polite than J.B., I think you&#8217;ve completely missed the point on the third. Your strawman description is a travesty of what TDD with Mocks should be about. It does describe a naive approach that has become too widespread, but raw critical postings like this one have the unfortunate effect of perpetuating the broken ideas.</p>
<p>I&#8217;d even disagree with J.B., in that mocking expensive external resources is absolutely the wrong way to introduce the ideas. The important thing is to think about how object collaborate and what services they need from their neighbours, so Joe Walnes&#8217; Novice rule is &#8220;Only mock types you own&#8221; &#8212; that way one can concentrate on design issues not performance. </p>
<p>Although some people have practised it forever, TDD is still very early in its adoption curve. Given the proportion of programmers who still struggle with OO concepts, we should be clear about when TDD practices are fundamentally broken and when they suffer from weak skills.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: J. B. Rainsberger</title>
		<link>http://cafe.elharo.com/testing/harolds-corollary-to-knuths-law/#comment-261066</link>
		<dc:creator>J. B. Rainsberger</dc:creator>
		<pubDate>Tue, 12 Aug 2008 17:39:17 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/?p=246#comment-261066</guid>
		<description>I don't use test doubles (aka "mocks") as a test execution optimization any more. They constitute a design tool for me: they allow me to Worry About One Thing At A Time when I test-drive behavior. That they allow me to run 95% of my tests at 250 tests per second is a pleasant side effect. Of course, I went through the phase of "mock expensive external resources" and I believe that remains an excellent Novice (in the Dreyfus sense) rule to follow.</description>
		<content:encoded><![CDATA[<p>I don&#8217;t use test doubles (aka &#8220;mocks&#8221;) as a test execution optimization any more. They constitute a design tool for me: they allow me to Worry About One Thing At A Time when I test-drive behavior. That they allow me to run 95% of my tests at 250 tests per second is a pleasant side effect. Of course, I went through the phase of &#8220;mock expensive external resources&#8221; and I believe that remains an excellent Novice (in the Dreyfus sense) rule to follow.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ravi Venkataraman</title>
		<link>http://cafe.elharo.com/testing/harolds-corollary-to-knuths-law/#comment-260527</link>
		<dc:creator>Ravi Venkataraman</dc:creator>
		<pubDate>Mon, 11 Aug 2008 13:23:05 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/?p=246#comment-260527</guid>
		<description>Brendan, I believe it was Michael and ERH who brought up the topic. I merely asked about the validity of a technique that can so easily lead to bad coding habits.</description>
		<content:encoded><![CDATA[<p>Brendan, I believe it was Michael and ERH who brought up the topic. I merely asked about the validity of a technique that can so easily lead to bad coding habits.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brendan Johnston</title>
		<link>http://cafe.elharo.com/testing/harolds-corollary-to-knuths-law/#comment-260374</link>
		<dc:creator>Brendan Johnston</dc:creator>
		<pubDate>Mon, 11 Aug 2008 04:30:22 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/?p=246#comment-260374</guid>
		<description>We should not assume without proof that the best set of tests are "unit tests".  Elliot is communicating that he has been more effective writing tests which orchestrate more than one unit.

As Elliot and Harald K suggest both performance and robustness should guide the selection of tests in the suite.  These should be real values, not potential performance and robustness.

Ravi, TDD has not promoted long private methods when I used it.

Michael, permission for more thoughtful exploration of the solution may be part of the value of TDD.  Refactoring to some standard of cyclomatic complexity, method length of some other metric may be add as much to the design.

Harald, I believe there are many examples of quality software produced without either unit or integration tests.</description>
		<content:encoded><![CDATA[<p>We should not assume without proof that the best set of tests are &#8220;unit tests&#8221;.  Elliot is communicating that he has been more effective writing tests which orchestrate more than one unit.</p>
<p>As Elliot and Harald K suggest both performance and robustness should guide the selection of tests in the suite.  These should be real values, not potential performance and robustness.</p>
<p>Ravi, TDD has not promoted long private methods when I used it.</p>
<p>Michael, permission for more thoughtful exploration of the solution may be part of the value of TDD.  Refactoring to some standard of cyclomatic complexity, method length of some other metric may be add as much to the design.</p>
<p>Harald, I believe there are many examples of quality software produced without either unit or integration tests.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex Martelli</title>
		<link>http://cafe.elharo.com/testing/harolds-corollary-to-knuths-law/#comment-260314</link>
		<dc:creator>Alex Martelli</dc:creator>
		<pubDate>Sun, 10 Aug 2008 23:28:00 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/?p=246#comment-260314</guid>
		<description>100% agree with Harald K, and raising it -- the parts that are *most* important to tests are the failure cases -- are they all handled correctly, etc, etc.  I've spent the last few years of my life mostly doing cluster management software, and those parts are the real reason for having such SW in the first place -- what happens if the database goes down at the same time as the sensors are telling you that temperatures are rising dangerously fast?  What happens if both the first-line and backup alerts to the pagers are getting ignored in a critical situation?  Etc, etc -- people who don't GET mocks are apparently saying I should actually be setting datacenters on fire, paging operators all over the place, and sabotaging the servers on which the database run, to really test the most important parts of my software... *PAH*!

BUT, ensuring that failures are handled perfectly is just as crucial on the other end of the stack -- cfr 37signals' book on "Defensive Design for the Web" for a somewhat-rambling but overall useful tome on that.  Take care of failures, problems, and all sorts of exceptional conditions that you can only really test via mocks, and the normal "mainstream" flow will take care of itself, or, darn near;-).


Alex</description>
		<content:encoded><![CDATA[<p>100% agree with Harald K, and raising it &#8212; the parts that are *most* important to tests are the failure cases &#8212; are they all handled correctly, etc, etc.  I&#8217;ve spent the last few years of my life mostly doing cluster management software, and those parts are the real reason for having such SW in the first place &#8212; what happens if the database goes down at the same time as the sensors are telling you that temperatures are rising dangerously fast?  What happens if both the first-line and backup alerts to the pagers are getting ignored in a critical situation?  Etc, etc &#8212; people who don&#8217;t GET mocks are apparently saying I should actually be setting datacenters on fire, paging operators all over the place, and sabotaging the servers on which the database run, to really test the most important parts of my software&#8230; *PAH*!</p>
<p>BUT, ensuring that failures are handled perfectly is just as crucial on the other end of the stack &#8212; cfr 37signals&#8217; book on &#8220;Defensive Design for the Web&#8221; for a somewhat-rambling but overall useful tome on that.  Take care of failures, problems, and all sorts of exceptional conditions that you can only really test via mocks, and the normal &#8220;mainstream&#8221; flow will take care of itself, or, darn near;-).</p>
<p>Alex</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gareth Rees</title>
		<link>http://cafe.elharo.com/testing/harolds-corollary-to-knuths-law/#comment-259518</link>
		<dc:creator>Gareth Rees</dc:creator>
		<pubDate>Sat, 09 Aug 2008 15:52:41 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/?p=246#comment-259518</guid>
		<description>&lt;i&gt;Are there some tests that are so slow they contribute to not running the test suite? Yes. We’ve all seen them, but there’s no way to tell which tests they are in advance&lt;/i&gt;

Combinatorial test generators can generate an infinite number of different tests. See for example, Miller, Fredriksen and So (1990), “&lt;a href="ftp://ftp.cs.wisc.edu/paradyn/technical_papers/fuzz.pdf" rel="nofollow"&gt;An Empirical Study of the Reliability of UNIX Utilities&lt;/a&gt;” or Eide and Regehr (2008), “&lt;a href="http://www.cs.utah.edu/~regehr/papers/emsoft08-preprint.pdf" rel="nofollow"&gt;Volatiles Are Miscompiled, and What to Do about It&lt;/a&gt;”. 

So the issue of “how many tests is it worth running?” arises immediately.

The development strategy of having just one test suite that you run on every build doesn’t scale to large projects or large numbers of tests.  You need some kind of hierarchy of tests: a basic set that you run before every commit; a larger set that you run regularly, and even larger sets that you run rarely, for example in the run-up to public releases.</description>
		<content:encoded><![CDATA[<p><i>Are there some tests that are so slow they contribute to not running the test suite? Yes. We’ve all seen them, but there’s no way to tell which tests they are in advance</i></p>
<p>Combinatorial test generators can generate an infinite number of different tests. See for example, Miller, Fredriksen and So (1990), “<a href="ftp://ftp.cs.wisc.edu/paradyn/technical_papers/fuzz.pdf" onclick="javascript:pageTracker._trackPageview('/outbound/comment/ftp.cs.wisc.edu');" rel="nofollow">An Empirical Study of the Reliability of UNIX Utilities</a>” or Eide and Regehr (2008), “<a href="http://www.cs.utah.edu/~regehr/papers/emsoft08-preprint.pdf" onclick="javascript:pageTracker._trackPageview('/outbound/comment/www.cs.utah.edu');" rel="nofollow">Volatiles Are Miscompiled, and What to Do about It</a>”. </p>
<p>So the issue of “how many tests is it worth running?” arises immediately.</p>
<p>The development strategy of having just one test suite that you run on every build doesn’t scale to large projects or large numbers of tests.  You need some kind of hierarchy of tests: a basic set that you run before every commit; a larger set that you run regularly, and even larger sets that you run rarely, for example in the run-up to public releases.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harald K.</title>
		<link>http://cafe.elharo.com/testing/harolds-corollary-to-knuths-law/#comment-259070</link>
		<dc:creator>Harald K.</dc:creator>
		<pubDate>Fri, 08 Aug 2008 10:25:12 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/?p=246#comment-259070</guid>
		<description>It's not hard to agree with items 1 and 2, to me this is obvious (just a short warning, I'm not a hard-core TDD'er myself, as I seldom start writing tests before I have some of the API ready). But I think ERH misses the point of mock objects. 

The main reason I test with mocks is not performance or optimization, but predictability (also in the time it takes to run the test, but that's just a minor part of it). 

My mocks don't start failing the 42nd time I run the test, because the network was down, some db table was corrupted, or a disk was full. They just run. I also make my mocks fail predictably, so that I can test that the API handles these failure conditions gracefully. Such conditions are really hard to test using the "real thing". How do you make sure you gracefully handle a socket timeout, an I/O-exception in the middle of a stream etc, using the "real thing"? In additions, mocks can have expectations on them, that can be used to verify the API does what it's supposed to. If you test with the "real thing" do you build the verification into your implementation?

Another thing to point out, is that even if integration tests and unit test are different beasts, it's never one or the other. To create quality software you need both.</description>
		<content:encoded><![CDATA[<p>It&#8217;s not hard to agree with items 1 and 2, to me this is obvious (just a short warning, I&#8217;m not a hard-core TDD&#8217;er myself, as I seldom start writing tests before I have some of the API ready). But I think ERH misses the point of mock objects. </p>
<p>The main reason I test with mocks is not performance or optimization, but predictability (also in the time it takes to run the test, but that&#8217;s just a minor part of it). </p>
<p>My mocks don&#8217;t start failing the 42nd time I run the test, because the network was down, some db table was corrupted, or a disk was full. They just run. I also make my mocks fail predictably, so that I can test that the API handles these failure conditions gracefully. Such conditions are really hard to test using the &#8220;real thing&#8221;. How do you make sure you gracefully handle a socket timeout, an I/O-exception in the middle of a stream etc, using the &#8220;real thing&#8221;? In additions, mocks can have expectations on them, that can be used to verify the API does what it&#8217;s supposed to. If you test with the &#8220;real thing&#8221; do you build the verification into your implementation?</p>
<p>Another thing to point out, is that even if integration tests and unit test are different beasts, it&#8217;s never one or the other. To create quality software you need both.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ravi Venkataraman</title>
		<link>http://cafe.elharo.com/testing/harolds-corollary-to-knuths-law/#comment-258647</link>
		<dc:creator>Ravi Venkataraman</dc:creator>
		<pubDate>Thu, 07 Aug 2008 16:17:15 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/?p=246#comment-258647</guid>
		<description>I agree wholeheartedly with ERH on this topic. I have never understood the fascination with unit tests. or mocks, or TDD.

Unit tests only go so far, and in no way "prove" that the requirements will be met. Mocks are an abomination, requiring far too much effort to build. I prefer to test against the "real" environment, for exactly the same reasons that ERH stated - it is more realistic and is much more likely to flesh out actual problems. initially,  I may use stubs that return "expected" values and then move on to the "real" environment.

As far as TDD goes, it is simply the wrong way to design software, elegant algorithms seldom arise from it. And TDD is never needed if we are familiar with the problem. It will lead to all sorts of bad design. If, as Michael points out, large private methods are a code smell, all I can ask is - but aren't these methods the result of doing TDD? If so, what value does TDD have as a design tool if it often leads to bad code? Wouldn't the average programmer be better off writing the correct code without TDD?</description>
		<content:encoded><![CDATA[<p>I agree wholeheartedly with ERH on this topic. I have never understood the fascination with unit tests. or mocks, or TDD.</p>
<p>Unit tests only go so far, and in no way &#8220;prove&#8221; that the requirements will be met. Mocks are an abomination, requiring far too much effort to build. I prefer to test against the &#8220;real&#8221; environment, for exactly the same reasons that ERH stated - it is more realistic and is much more likely to flesh out actual problems. initially,  I may use stubs that return &#8220;expected&#8221; values and then move on to the &#8220;real&#8221; environment.</p>
<p>As far as TDD goes, it is simply the wrong way to design software, elegant algorithms seldom arise from it. And TDD is never needed if we are familiar with the problem. It will lead to all sorts of bad design. If, as Michael points out, large private methods are a code smell, all I can ask is - but aren&#8217;t these methods the result of doing TDD? If so, what value does TDD have as a design tool if it often leads to bad code? Wouldn&#8217;t the average programmer be better off writing the correct code without TDD?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Feathers</title>
		<link>http://cafe.elharo.com/testing/harolds-corollary-to-knuths-law/#comment-258075</link>
		<dc:creator>Michael Feathers</dc:creator>
		<pubDate>Wed, 06 Aug 2008 20:12:57 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/?p=246#comment-258075</guid>
		<description>Elliotte, fair enough on adding setters, and making fields public when TDDing greenfield.  I don't encourage that at all.  And, all of those things are really seeking shortcuts rather than using testability as a gauge of design.  

The thing that I do encourage is a rethink at a deeper level.  It's not uncommon to TDD a class and notice that some set of private methods are becoming uncomfortably complex.. complex in the sense that you can test them through the public interface but you'd much rather test them directly.  

What is interesting to me is just how often this correlates to "complex enough to be its own class."  It's easy to munge responsibilities together in code, and testing is an excellent probe.  I guess, at the core, If it's hard to write a test for something, it's hard to claim that you understand it.  Putting values in and knowing what the values should be coming back is where the rubber hits the pavement.   If we notice the problem and split those private methods (and they data that the operate upon) into another class, it can be a win in terms of cohesion, coupling, and understandability.</description>
		<content:encoded><![CDATA[<p>Elliotte, fair enough on adding setters, and making fields public when TDDing greenfield.  I don&#8217;t encourage that at all.  And, all of those things are really seeking shortcuts rather than using testability as a gauge of design.  </p>
<p>The thing that I do encourage is a rethink at a deeper level.  It&#8217;s not uncommon to TDD a class and notice that some set of private methods are becoming uncomfortably complex.. complex in the sense that you can test them through the public interface but you&#8217;d much rather test them directly.  </p>
<p>What is interesting to me is just how often this correlates to &#8220;complex enough to be its own class.&#8221;  It&#8217;s easy to munge responsibilities together in code, and testing is an excellent probe.  I guess, at the core, If it&#8217;s hard to write a test for something, it&#8217;s hard to claim that you understand it.  Putting values in and knowing what the values should be coming back is where the rubber hits the pavement.   If we notice the problem and split those private methods (and they data that the operate upon) into another class, it can be a win in terms of cohesion, coupling, and understandability.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
