<?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: DoubleDawg 3A: A Gnarly Judgment Call</title>
	<atom:link href="http://anarchycreek.com/2009/08/27/doubledawg-3a-a-gnarly-judgment-call/feed/" rel="self" type="application/rss+xml" />
	<link>http://anarchycreek.com/2009/08/27/doubledawg-3a-a-gnarly-judgment-call/</link>
	<description>Towards a Way of Excellence</description>
	<lastBuildDate>Fri, 06 Jan 2012 00:33:30 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
	<item>
		<title>By: Jeff Grigg</title>
		<link>http://anarchycreek.com/2009/08/27/doubledawg-3a-a-gnarly-judgment-call/comment-page-1/#comment-865</link>
		<dc:creator>Jeff Grigg</dc:creator>
		<pubDate>Mon, 11 Jan 2010 22:42:12 +0000</pubDate>
		<guid isPermaLink="false">http://anarchycreek.com/?p=633#comment-865</guid>
		<description>Regarding “Should you not have a test in place that ensures that the processAnnotations method does not return null?”

It’s very difficult to write a test to ensure that a function NEVER returns null.  To do that, I’d have to test every possible scenario and ensure that none of them return null.

But all is not lost…
If we remove the null checks from the calling code and then run a good set of tests on the calling code, then the fact that the calling code does not suffer a NullPointerException is good evidence that the null checks were not needed.  In fact, it’s a fairly strong test because we are already testing a case where we might fear that lists or arrays might reasonably be null or empty:  We’re testing a class with no class annotations and no methods.  We might worry that nulls might occur in an edge case like this.  But running the tests, we see that there is no problem.</description>
		<content:encoded><![CDATA[<p>Regarding “Should you not have a test in place that ensures that the processAnnotations method does not return null?”</p>
<p>It’s very difficult to write a test to ensure that a function NEVER returns null.  To do that, I’d have to test every possible scenario and ensure that none of them return null.</p>
<p>But all is not lost…<br />
If we remove the null checks from the calling code and then run a good set of tests on the calling code, then the fact that the calling code does not suffer a NullPointerException is good evidence that the null checks were not needed.  In fact, it’s a fairly strong test because we are already testing a case where we might fear that lists or arrays might reasonably be null or empty:  We’re testing a class with no class annotations and no methods.  We might worry that nulls might occur in an edge case like this.  But running the tests, we see that there is no problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Grigg</title>
		<link>http://anarchycreek.com/2009/08/27/doubledawg-3a-a-gnarly-judgment-call/comment-page-1/#comment-862</link>
		<dc:creator>Jeff Grigg</dc:creator>
		<pubDate>Mon, 11 Jan 2010 22:28:08 +0000</pubDate>
		<guid isPermaLink="false">http://anarchycreek.com/?p=633#comment-862</guid>
		<description>Question:  How do I know that the processAnnotations method does not and cannot return null?

The method looks like this:
private List processAnnotations(Object o) {
  List result = new ArrayList();
  [... lots of nasty complex code ...]
  return result;
}

So really the question is, &quot;What if someone assigns &#039;result=null;&#039; in the middle of the method?

Well, I looked.  There is no such assignment.

And if some later programmer introduces such a bug, then I think that they need to take responsibility for their actions.  ;-&gt;

And if I&#039;m afraid that someone might accidentally do that, I can discourage them from doing so by adding the word &quot;final&quot;, like this:
private List processAnnotations(Object o) {
  final List result = new ArrayList();
  [... lots of nasty complex code ...]
  return result;
}
Now everyone who looks at the first and last lines of this method will *KNOW* that it never returns null.</description>
		<content:encoded><![CDATA[<p>Question:  How do I know that the processAnnotations method does not and cannot return null?</p>
<p>The method looks like this:<br />
private List processAnnotations(Object o) {<br />
  List result = new ArrayList();<br />
  [... lots of nasty complex code ...]<br />
  return result;<br />
}</p>
<p>So really the question is, &#8220;What if someone assigns &#8216;result=null;&#8217; in the middle of the method?</p>
<p>Well, I looked.  There is no such assignment.</p>
<p>And if some later programmer introduces such a bug, then I think that they need to take responsibility for their actions.  ;-&gt;</p>
<p>And if I&#8217;m afraid that someone might accidentally do that, I can discourage them from doing so by adding the word &#8220;final&#8221;, like this:<br />
private List processAnnotations(Object o) {<br />
  final List result = new ArrayList();<br />
  [... lots of nasty complex code ...]<br />
  return result;<br />
}<br />
Now everyone who looks at the first and last lines of this method will *KNOW* that it never returns null.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: GeePawHill</title>
		<link>http://anarchycreek.com/2009/08/27/doubledawg-3a-a-gnarly-judgment-call/comment-page-1/#comment-204</link>
		<dc:creator>GeePawHill</dc:creator>
		<pubDate>Mon, 31 Aug 2009 21:22:12 +0000</pubDate>
		<guid isPermaLink="false">http://anarchycreek.com/?p=633#comment-204</guid>
		<description>It is my fondest hope that your love was unrequited, or at the very least, you two were unable to have children. -- GeePaw</description>
		<content:encoded><![CDATA[<p>It is my fondest hope that your love was unrequited, or at the very least, you two were unable to have children. &#8212; GeePaw</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert Higgins</title>
		<link>http://anarchycreek.com/2009/08/27/doubledawg-3a-a-gnarly-judgment-call/comment-page-1/#comment-203</link>
		<dc:creator>Robert Higgins</dc:creator>
		<pubDate>Mon, 31 Aug 2009 14:18:54 +0000</pubDate>
		<guid isPermaLink="false">http://anarchycreek.com/?p=633#comment-203</guid>
		<description>I once fail in love with a girl on site, in Duragno her name is Mary.  She said her first girl would be Gnarleen and her Boy would be Radly.</description>
		<content:encoded><![CDATA[<p>I once fail in love with a girl on site, in Duragno her name is Mary.  She said her first girl would be Gnarleen and her Boy would be Radly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Premature optimization is the root of all evil, or is it? &#124; Codedstyle</title>
		<link>http://anarchycreek.com/2009/08/27/doubledawg-3a-a-gnarly-judgment-call/comment-page-1/#comment-202</link>
		<dc:creator>Premature optimization is the root of all evil, or is it? &#124; Codedstyle</dc:creator>
		<pubDate>Sun, 30 Aug 2009 16:22:16 +0000</pubDate>
		<guid isPermaLink="false">http://anarchycreek.com/?p=633#comment-202</guid>
		<description>[...] will pass just because to document the expected behavior? Sometimes yes, but not always as this post points [...]</description>
		<content:encoded><![CDATA[<p>[...] will pass just because to document the expected behavior? Sometimes yes, but not always as this post points [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arielr</title>
		<link>http://anarchycreek.com/2009/08/27/doubledawg-3a-a-gnarly-judgment-call/comment-page-1/#comment-201</link>
		<dc:creator>Arielr</dc:creator>
		<pubDate>Sun, 30 Aug 2009 08:11:03 +0000</pubDate>
		<guid isPermaLink="false">http://anarchycreek.com/?p=633#comment-201</guid>
		<description>Good read. I agree with all the &quot;blah&quot;.

On the technical question at hand - the concept of code contracts solves this very issue.</description>
		<content:encoded><![CDATA[<p>Good read. I agree with all the &#8220;blah&#8221;.</p>
<p>On the technical question at hand &#8211; the concept of code contracts solves this very issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sam</title>
		<link>http://anarchycreek.com/2009/08/27/doubledawg-3a-a-gnarly-judgment-call/comment-page-1/#comment-196</link>
		<dc:creator>sam</dc:creator>
		<pubDate>Fri, 28 Aug 2009 15:10:55 +0000</pubDate>
		<guid isPermaLink="false">http://anarchycreek.com/?p=633#comment-196</guid>
		<description>thanks for the full reply.  These completeness v pragmatic issues are ones that, with limited time and deadlines to meet, often have to be played off against each other.  I think I would have probably made a similar call, and noted in the javadoc for the method that it will never return null.  Then if someone did make it return null, I would at least have a little something to beat them with.</description>
		<content:encoded><![CDATA[<p>thanks for the full reply.  These completeness v pragmatic issues are ones that, with limited time and deadlines to meet, often have to be played off against each other.  I think I would have probably made a similar call, and noted in the javadoc for the method that it will never return null.  Then if someone did make it return null, I would at least have a little something to beat them with.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

