<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Forget about Hope Driven Development (HDD), the cancer of software development.</title>
	<atom:link href="http://www.makinggoodsoftware.com/2009/05/12/hdd/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.makinggoodsoftware.com/2009/05/12/hdd/</link>
	<description></description>
	<lastBuildDate>Thu, 29 Jul 2010 10:36:55 -0600</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.3</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: ertan</title>
		<link>http://www.makinggoodsoftware.com/2009/05/12/hdd/comment-page-1/#comment-9537</link>
		<dc:creator>ertan</dc:creator>
		<pubDate>Sat, 10 Jul 2010 12:50:16 +0000</pubDate>
		<guid isPermaLink="false">http://makinggoodsoftware.com/?p=128#comment-9537</guid>
		<description>thanks for article alberto. my choise 2, prevent hdd :)</description>
		<content:encoded><![CDATA[<p>thanks for article alberto. my choise 2, prevent hdd <img src='http://www.makinggoodsoftware.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 大學沒教的 10 + 1 件關於程式設計的事</title>
		<link>http://www.makinggoodsoftware.com/2009/05/12/hdd/comment-page-1/#comment-7914</link>
		<dc:creator>大學沒教的 10 + 1 件關於程式設計的事</dc:creator>
		<pubDate>Fri, 28 May 2010 15:37:33 +0000</pubDate>
		<guid isPermaLink="false">http://makinggoodsoftware.com/?p=128#comment-7914</guid>
		<description>[...] 也有人說，「希望能促進開發」，若你對於某些事並不確定，或是你發現你自己使用了「應該」這個詞彙，那麼你麻煩就大了。 [...]</description>
		<content:encoded><![CDATA[<p>[...] 也有人說，「希望能促進開發」，若你對於某些事並不確定，或是你發現你自己使用了「應該」這個詞彙，那麼你麻煩就大了。 [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tungano</title>
		<link>http://www.makinggoodsoftware.com/2009/05/12/hdd/comment-page-1/#comment-7350</link>
		<dc:creator>Tungano</dc:creator>
		<pubDate>Tue, 11 May 2010 14:59:17 +0000</pubDate>
		<guid isPermaLink="false">http://makinggoodsoftware.com/?p=128#comment-7350</guid>
		<description>@Tz

You make a good point when it comes to the public bit, if there is no obvious other user of the method it has no business being public (for the time being).
The method itself can still be valid for other reasons, SRP and encapsulation come to mind.
 
If Martin is really sure about his code then he doesn&#039;t need to add a try/catch block to catch anything does he? (don&#039;t use CheckedExceptions if you are working in Java) Remember that he is the source of the exception, not a victim.

However if he does make a mistake John&#039;s method will make that apparent. This is a basic &#039;fail fast&#039; concept. Without the exception Martin will first have to dig through John&#039;s method to figure out what&#039;s going wrong.

Also if Martin is unit testing his code he will get these same exceptions as his code calls John&#039;s. In my view this will actually -help- Martin make his code more robust.

If Martin does call John with bad data I see it as a requirement that Martin handles this. How can John possible know how to resolve the issue, it&#039;s out of it&#039;s context? It&#039;s a precondition thing; &quot;I can&#039;t service you given this&quot;.

In a public scenario I do unit test for all exceptions on John&#039;s method. I do not unit test private methods, if John&#039;s method would be private I would test Martin&#039;s method only.

Typically I don&#039;t put pre-condition expections in private methods but I may put in some asserts which the compiler can drop when building a release.

Constraining the method input supporting on the compilers type checking is also a good solution, be it booleans, enums or whatever. Not always possible though.</description>
		<content:encoded><![CDATA[<p>@Tz</p>
<p>You make a good point when it comes to the public bit, if there is no obvious other user of the method it has no business being public (for the time being).<br />
The method itself can still be valid for other reasons, SRP and encapsulation come to mind.</p>
<p>If Martin is really sure about his code then he doesn&#8217;t need to add a try/catch block to catch anything does he? (don&#8217;t use CheckedExceptions if you are working in Java) Remember that he is the source of the exception, not a victim.</p>
<p>However if he does make a mistake John&#8217;s method will make that apparent. This is a basic &#8216;fail fast&#8217; concept. Without the exception Martin will first have to dig through John&#8217;s method to figure out what&#8217;s going wrong.</p>
<p>Also if Martin is unit testing his code he will get these same exceptions as his code calls John&#8217;s. In my view this will actually -help- Martin make his code more robust.</p>
<p>If Martin does call John with bad data I see it as a requirement that Martin handles this. How can John possible know how to resolve the issue, it&#8217;s out of it&#8217;s context? It&#8217;s a precondition thing; &#8220;I can&#8217;t service you given this&#8221;.</p>
<p>In a public scenario I do unit test for all exceptions on John&#8217;s method. I do not unit test private methods, if John&#8217;s method would be private I would test Martin&#8217;s method only.</p>
<p>Typically I don&#8217;t put pre-condition expections in private methods but I may put in some asserts which the compiler can drop when building a release.</p>
<p>Constraining the method input supporting on the compilers type checking is also a good solution, be it booleans, enums or whatever. Not always possible though.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rick Minerich</title>
		<link>http://www.makinggoodsoftware.com/2009/05/12/hdd/comment-page-1/#comment-7349</link>
		<dc:creator>Rick Minerich</dc:creator>
		<pubDate>Tue, 11 May 2010 14:19:02 +0000</pubDate>
		<guid isPermaLink="false">http://makinggoodsoftware.com/?p=128#comment-7349</guid>
		<description>I agree that hope driven development is a problem, but your approach isn&#039;t much better and comes across as dangerous and naive.

Formal planning and requirements are key, but you don&#039;t mention them at all. Not every program needs a complete suite of unit tests, it depends on the scope and lifecycle of the project. Similarly, performance is a requirement, and so should be quantified before any code is written.</description>
		<content:encoded><![CDATA[<p>I agree that hope driven development is a problem, but your approach isn&#8217;t much better and comes across as dangerous and naive.</p>
<p>Formal planning and requirements are key, but you don&#8217;t mention them at all. Not every program needs a complete suite of unit tests, it depends on the scope and lifecycle of the project. Similarly, performance is a requirement, and so should be quantified before any code is written.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tz</title>
		<link>http://www.makinggoodsoftware.com/2009/05/12/hdd/comment-page-1/#comment-6938</link>
		<dc:creator>tz</dc:creator>
		<pubDate>Tue, 27 Apr 2010 16:31:37 +0000</pubDate>
		<guid isPermaLink="false">http://makinggoodsoftware.com/?p=128#comment-6938</guid>
		<description>You called HHD a cancer, but is the alternative exception handling metastasis?

And what if in the exception handler we run out of memory or the error logging connection breaks?  Ah we need yet another layer of exception handling to handle the exceptions caused on the original exception handler - disks get full, you know.  Or do you just &quot;hope&quot; the error message will be logged properly, or the dialog box will get on the screen.  And we need unit tests for all that too...

This has gotten too long already, as would the code.

John should trust Martin is good enough, or if he isn&#039;t change the interface so it depends neither on Martin&#039;s ability to send good values, or John&#039;s (and everyone else&#039;s) ability to handle bad ones properly.</description>
		<content:encoded><![CDATA[<p>You called HHD a cancer, but is the alternative exception handling metastasis?</p>
<p>And what if in the exception handler we run out of memory or the error logging connection breaks?  Ah we need yet another layer of exception handling to handle the exceptions caused on the original exception handler &#8211; disks get full, you know.  Or do you just &#8220;hope&#8221; the error message will be logged properly, or the dialog box will get on the screen.  And we need unit tests for all that too&#8230;</p>
<p>This has gotten too long already, as would the code.</p>
<p>John should trust Martin is good enough, or if he isn&#8217;t change the interface so it depends neither on Martin&#8217;s ability to send good values, or John&#8217;s (and everyone else&#8217;s) ability to handle bad ones properly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tz</title>
		<link>http://www.makinggoodsoftware.com/2009/05/12/hdd/comment-page-1/#comment-6936</link>
		<dc:creator>tz</dc:creator>
		<pubDate>Tue, 27 Apr 2010 16:24:03 +0000</pubDate>
		<guid isPermaLink="false">http://makinggoodsoftware.com/?p=128#comment-6936</guid>
		<description>Clarification - if the input can only have two valid values, it should be a bool, isAandNotB, or vice versa, even if John&#039;s class is doing something complex involving private members of his class, but it begs the question as to why there is exactly one different class calling that method.  Something is very likely wrong in the design.

It seems very popular to fragment things into as many objects and classes and methods as possible, but this is bad design, not much different than being paid in KLoCs (thousand lines of code).

Often, when I hear a story like this (and I&#039;m probably oversensitive), the two classes should be one larger class.

I&#039;ve seen so much bad, fragmented C++ that suffered from this.

The designs I have seen that were blocked off into classes without trying to minimize the interfaces, and rules are put in place to &quot;check everything&quot; without a good guide as to what to do or even probability (the CPU is overheating so changes the value in its register).

If a method can only take two values make it a bool.  If three, an enum or an array with 3 members.

If divide by zero will be a problem, try to mathematically transform it so you don&#039;t need a divide.

Tell me how many new() methods do the right thing when memory allocation fails.  Allocating statically might waste things at times, but the breakage is immediate and constant.

HDD is having a spare tank of gas, radiator fluid, and spare tire because you built the car to break down, or can&#039;t be sure it won&#039;t.

It is much harder to design the structure so that it can&#039;t break, isn&#039;t dependent, has no &quot;invalid inputs&quot;, but that will result in high quality code.

And it may not be harder than peppering exceptions and try/catch blocks through the code.  Will you really code unit tests for EVERY exception condition?

Making it bool gives it two possible inputs and whatever complexity it does internally.  Adding the test for validity means you need to test every other possible wrong input (e.g. 257 is treated like 1 instead of being detected), and then also write the code not to just examine the internal state change and outputs, but do whatever handling, typically exception handling, used to detect the error.

Then, since it is in the definition of that method, the test fixture for the calling class has to be modified to cause the same thing to happen - or not?  

That was the conversation - does Martin&#039;s class handle it when whatever error detection happens - if Martin ever sent a wrong value into John&#039;s method, Martin&#039;s class now needs to deal with the fallout - but how do you test that if Martin&#039;s class always sends in correct data?  Occasionally treat valid data as invalid to insure Martin&#039;s upstream handling is OK?

Then there&#039;s those who call Martin&#039;s methods, if any (hence my merge the classes comment).  Every one of them will have to handle whatever Martin does to handle John&#039;s action in the invalid input case.

So now the code around the interface is 10x larger and more complex, and we really hope the unit tests we are writing will trigger things properly and that we didn&#039;t miss anything or introduce more numerous and subtle bugs with the full and properly implemented validity checks at all levels than were likely to be there originally.

Or you code some simple, throwaway handling and use the same HHD you originally criticize to avoid validating the entire exception handling chain.

Try working through the original example and remove HHD completely, not just from the first level.

And my suggestion - make it a bool so it can&#039;t be invalid by definition.  The code still needs to be tested, but the number of cases is now far more limited.</description>
		<content:encoded><![CDATA[<p>Clarification &#8211; if the input can only have two valid values, it should be a bool, isAandNotB, or vice versa, even if John&#8217;s class is doing something complex involving private members of his class, but it begs the question as to why there is exactly one different class calling that method.  Something is very likely wrong in the design.</p>
<p>It seems very popular to fragment things into as many objects and classes and methods as possible, but this is bad design, not much different than being paid in KLoCs (thousand lines of code).</p>
<p>Often, when I hear a story like this (and I&#8217;m probably oversensitive), the two classes should be one larger class.</p>
<p>I&#8217;ve seen so much bad, fragmented C++ that suffered from this.</p>
<p>The designs I have seen that were blocked off into classes without trying to minimize the interfaces, and rules are put in place to &#8220;check everything&#8221; without a good guide as to what to do or even probability (the CPU is overheating so changes the value in its register).</p>
<p>If a method can only take two values make it a bool.  If three, an enum or an array with 3 members.</p>
<p>If divide by zero will be a problem, try to mathematically transform it so you don&#8217;t need a divide.</p>
<p>Tell me how many new() methods do the right thing when memory allocation fails.  Allocating statically might waste things at times, but the breakage is immediate and constant.</p>
<p>HDD is having a spare tank of gas, radiator fluid, and spare tire because you built the car to break down, or can&#8217;t be sure it won&#8217;t.</p>
<p>It is much harder to design the structure so that it can&#8217;t break, isn&#8217;t dependent, has no &#8220;invalid inputs&#8221;, but that will result in high quality code.</p>
<p>And it may not be harder than peppering exceptions and try/catch blocks through the code.  Will you really code unit tests for EVERY exception condition?</p>
<p>Making it bool gives it two possible inputs and whatever complexity it does internally.  Adding the test for validity means you need to test every other possible wrong input (e.g. 257 is treated like 1 instead of being detected), and then also write the code not to just examine the internal state change and outputs, but do whatever handling, typically exception handling, used to detect the error.</p>
<p>Then, since it is in the definition of that method, the test fixture for the calling class has to be modified to cause the same thing to happen &#8211; or not?  </p>
<p>That was the conversation &#8211; does Martin&#8217;s class handle it when whatever error detection happens &#8211; if Martin ever sent a wrong value into John&#8217;s method, Martin&#8217;s class now needs to deal with the fallout &#8211; but how do you test that if Martin&#8217;s class always sends in correct data?  Occasionally treat valid data as invalid to insure Martin&#8217;s upstream handling is OK?</p>
<p>Then there&#8217;s those who call Martin&#8217;s methods, if any (hence my merge the classes comment).  Every one of them will have to handle whatever Martin does to handle John&#8217;s action in the invalid input case.</p>
<p>So now the code around the interface is 10x larger and more complex, and we really hope the unit tests we are writing will trigger things properly and that we didn&#8217;t miss anything or introduce more numerous and subtle bugs with the full and properly implemented validity checks at all levels than were likely to be there originally.</p>
<p>Or you code some simple, throwaway handling and use the same HHD you originally criticize to avoid validating the entire exception handling chain.</p>
<p>Try working through the original example and remove HHD completely, not just from the first level.</p>
<p>And my suggestion &#8211; make it a bool so it can&#8217;t be invalid by definition.  The code still needs to be tested, but the number of cases is now far more limited.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tz</title>
		<link>http://www.makinggoodsoftware.com/2009/05/12/hdd/comment-page-1/#comment-6934</link>
		<dc:creator>tz</dc:creator>
		<pubDate>Tue, 27 Apr 2010 15:30:31 +0000</pubDate>
		<guid isPermaLink="false">http://makinggoodsoftware.com/?p=128#comment-6934</guid>
		<description>I would say that if John&#039;s class is the only one calling Martin&#039;s method, that method should be a private member of John&#039;s class.

Didn&#039;t anyone else notice this?

Also, if the parameter isn&#039;t A or B, does it throw and exception (so Martin needs try/catch all over the place)?  Does it return a default value?  Does it return it&#039;s own Out of Band value?  Does it simply do exit(666) into the abyss without leaving a stack trace?  

What makes anyone think whatever John does in response to detecting the error won&#039;t cause a worse problem than ignoring it?

Maybe it is
#define A TRUE
#define B FALSE
void martinsMethod( bool input) {
if (input != A &amp;&amp; input != B ) ...

No, the cancer is all those stupid design mistakes which are never corrected and arbitrary rules that created cluttered, complex code in the first place, but every method does all kinds of fancy checks for the most improbable events.

E.g. A 7 deep nest of methods will each dutifully check for a NULL pointer and just do nothing with it, so a security program which is validating a password will return OK instead of crashing with a segfault, letting the hacker through.  I would rather it crash and halt than try to continue spinning who knows where.

HDD - Horrid Dogmatic Design - is writing out the design - all the classes - at random before you have any idea what you really need to do - and using Hope that you can turn the monstrosity that you refuse to fix at the higher level into something that works by doing a perfect implementation.</description>
		<content:encoded><![CDATA[<p>I would say that if John&#8217;s class is the only one calling Martin&#8217;s method, that method should be a private member of John&#8217;s class.</p>
<p>Didn&#8217;t anyone else notice this?</p>
<p>Also, if the parameter isn&#8217;t A or B, does it throw and exception (so Martin needs try/catch all over the place)?  Does it return a default value?  Does it return it&#8217;s own Out of Band value?  Does it simply do exit(666) into the abyss without leaving a stack trace?  </p>
<p>What makes anyone think whatever John does in response to detecting the error won&#8217;t cause a worse problem than ignoring it?</p>
<p>Maybe it is<br />
#define A TRUE<br />
#define B FALSE<br />
void martinsMethod( bool input) {<br />
if (input != A &amp;&amp; input != B ) &#8230;</p>
<p>No, the cancer is all those stupid design mistakes which are never corrected and arbitrary rules that created cluttered, complex code in the first place, but every method does all kinds of fancy checks for the most improbable events.</p>
<p>E.g. A 7 deep nest of methods will each dutifully check for a NULL pointer and just do nothing with it, so a security program which is validating a password will return OK instead of crashing with a segfault, letting the hacker through.  I would rather it crash and halt than try to continue spinning who knows where.</p>
<p>HDD &#8211; Horrid Dogmatic Design &#8211; is writing out the design &#8211; all the classes &#8211; at random before you have any idea what you really need to do &#8211; and using Hope that you can turn the monstrosity that you refuse to fix at the higher level into something that works by doing a perfect implementation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Let Fortune Cookies Develop for you</title>
		<link>http://www.makinggoodsoftware.com/2009/05/12/hdd/comment-page-1/#comment-4593</link>
		<dc:creator>Let Fortune Cookies Develop for you</dc:creator>
		<pubDate>Mon, 01 Feb 2010 09:59:10 +0000</pubDate>
		<guid isPermaLink="false">http://makinggoodsoftware.com/?p=128#comment-4593</guid>
		<description>[...] recently read an article by Alberto Gutierrez where he&#8217;s talking about a thing he calls &#8216;Hope Driven Development&#8217; or HDD. And I [...]</description>
		<content:encoded><![CDATA[<p>[...] recently read an article by Alberto Gutierrez where he&#8217;s talking about a thing he calls &#8216;Hope Driven Development&#8217; or HDD. And I [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Giorgio Sironi</title>
		<link>http://www.makinggoodsoftware.com/2009/05/12/hdd/comment-page-1/#comment-4526</link>
		<dc:creator>Giorgio Sironi</dc:creator>
		<pubDate>Sat, 30 Jan 2010 12:08:18 +0000</pubDate>
		<guid isPermaLink="false">http://makinggoodsoftware.com/?p=128#comment-4526</guid>
		<description>I think for internal parameters the validation issues may be substituted by unit testing. You can check that the parameters passed to your constructors are valid, but this is going to clash with simple unit testing, where you are forced to initialize collaborators you do not use.</description>
		<content:encoded><![CDATA[<p>I think for internal parameters the validation issues may be substituted by unit testing. You can check that the parameters passed to your constructors are valid, but this is going to clash with simple unit testing, where you are forced to initialize collaborators you do not use.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: FizzBuzz &#187; Cleaning out the Bookmarks #5 &#8211; Hope Driven Development</title>
		<link>http://www.makinggoodsoftware.com/2009/05/12/hdd/comment-page-1/#comment-1661</link>
		<dc:creator>FizzBuzz &#187; Cleaning out the Bookmarks #5 &#8211; Hope Driven Development</dc:creator>
		<pubDate>Sun, 25 Oct 2009 16:37:58 +0000</pubDate>
		<guid isPermaLink="false">http://makinggoodsoftware.com/?p=128#comment-1661</guid>
		<description>[...] http://www.makinggoodsoftware.com/2009/05/12/hdd/ [...]</description>
		<content:encoded><![CDATA[<p>[...] <a href="http://www.makinggoodsoftware.com/2009/05/12/hdd/" rel="nofollow">http://www.makinggoodsoftware.com/2009/05/12/hdd/</a> [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
