<?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: Handling null in Java</title>
	<atom:link href="http://www.redcode.nl/blog/2010/02/handling-null-in-java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.redcode.nl/blog/2010/02/handling-null-in-java/</link>
	<description>Random</description>
	<lastBuildDate>Sat, 04 Sep 2010 01:24:17 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Jan de Ruiter</title>
		<link>http://www.redcode.nl/blog/2010/02/handling-null-in-java/comment-page-1/#comment-348</link>
		<dc:creator>Jan de Ruiter</dc:creator>
		<pubDate>Fri, 16 Apr 2010 15:52:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.redcode.nl/?p=340#comment-348</guid>
		<description>Nice article, but you make the world-with-null values look worse than necessary:
 for(Account account: accounts) {
   if(account != null) {
     totalBalance = totalBalance.add(account.getBalance());
   }
 }
If the accounts Set is empty, the for loop will not execute its body, so the inner if is not needed:
 for(Account account: accounts) {
   totalBalance = totalBalance.add(account.getBalance());
 }
account will always be set to some non-null value.</description>
		<content:encoded><![CDATA[<p>Nice article, but you make the world-with-null values look worse than necessary:<br />
 for(Account account: accounts) {<br />
   if(account != null) {<br />
     totalBalance = totalBalance.add(account.getBalance());<br />
   }<br />
 }<br />
If the accounts Set is empty, the for loop will not execute its body, so the inner if is not needed:<br />
 for(Account account: accounts) {<br />
   totalBalance = totalBalance.add(account.getBalance());<br />
 }<br />
account will always be set to some non-null value.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: "null", o una de las maldiciones de Java &#171; AOWS</title>
		<link>http://www.redcode.nl/blog/2010/02/handling-null-in-java/comment-page-1/#comment-112</link>
		<dc:creator>"null", o una de las maldiciones de Java &#171; AOWS</dc:creator>
		<pubDate>Thu, 04 Feb 2010 21:48:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.redcode.nl/?p=340#comment-112</guid>
		<description>[...] con valores nulos es, desde siempre, un dolor de muelas muy importante en el mundo de Java. En este artículo de Redcode nos lo recuerdan y proponen algunas de las pocas opciones que [...]</description>
		<content:encoded><![CDATA[<p>[...] con valores nulos es, desde siempre, un dolor de muelas muy importante en el mundo de Java. En este artículo de Redcode nos lo recuerdan y proponen algunas de las pocas opciones que [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Java4Learners</title>
		<link>http://www.redcode.nl/blog/2010/02/handling-null-in-java/comment-page-1/#comment-108</link>
		<dc:creator>Java4Learners</dc:creator>
		<pubDate>Thu, 04 Feb 2010 01:44:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.redcode.nl/?p=340#comment-108</guid>
		<description>This is good stuff. Its funny on face of it Java does not support pointers, yet throws a NullPointer Excpetion. A good programmers always make sure they check for null or at least make sure they have a catch block so that this NPE does not go through the stack. Rest all of these methods work to some extent and which one to choose depends on your context one is writing code under.</description>
		<content:encoded><![CDATA[<p>This is good stuff. Its funny on face of it Java does not support pointers, yet throws a NullPointer Excpetion. A good programmers always make sure they check for null or at least make sure they have a catch block so that this NPE does not go through the stack. Rest all of these methods work to some extent and which one to choose depends on your context one is writing code under.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Velis</title>
		<link>http://www.redcode.nl/blog/2010/02/handling-null-in-java/comment-page-1/#comment-105</link>
		<dc:creator>Andrew Velis</dc:creator>
		<pubDate>Wed, 03 Feb 2010 18:13:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.redcode.nl/?p=340#comment-105</guid>
		<description>Great post about using Null&#039;s in Java. I use Groovy at work and love the elvis operator. Now I can&#039;t live without it sometimes. It really is a shame that Java 7 didn&#039;t get the elvis operator.</description>
		<content:encoded><![CDATA[<p>Great post about using Null&#8217;s in Java. I use Groovy at work and love the elvis operator. Now I can&#8217;t live without it sometimes. It really is a shame that Java 7 didn&#8217;t get the elvis operator.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ara</title>
		<link>http://www.redcode.nl/blog/2010/02/handling-null-in-java/comment-page-1/#comment-96</link>
		<dc:creator>Ara</dc:creator>
		<pubDate>Tue, 02 Feb 2010 16:51:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.redcode.nl/?p=340#comment-96</guid>
		<description>If NULL is not a valid value (i.e., always a bug), then the @Nullable and @NotNull annotations make sense. If NULL *is* a valid value, however, then IMHO it is better to handle explicitly in code using IF statements. 

The Null object pattern, while convenient, seems dangerous because it can create hard-to-detect bugs. For example, let us assume that, in one case, NULL objects should return a result of NULL (or &quot;unknown person&quot; or &quot;N/A&quot; or...) but in another case they should result in a logic fork. An overworked programmer could easily forget about the logic fork and you get a runtime bug that only shows up in certain situations and whose detection is consequently dependent on having very good testing coverage. And then, assuming you detect it, you have to figure which method has the wrong logic in it.

If you don&#039;t use the Null object pattern, there is a chance you will get NullPointerException, but that&#039;s good because that means the application is fail-fast and you know exactly where you forget to do the check.</description>
		<content:encoded><![CDATA[<p>If NULL is not a valid value (i.e., always a bug), then the @Nullable and @NotNull annotations make sense. If NULL *is* a valid value, however, then IMHO it is better to handle explicitly in code using IF statements. </p>
<p>The Null object pattern, while convenient, seems dangerous because it can create hard-to-detect bugs. For example, let us assume that, in one case, NULL objects should return a result of NULL (or &#8220;unknown person&#8221; or &#8220;N/A&#8221; or&#8230;) but in another case they should result in a logic fork. An overworked programmer could easily forget about the logic fork and you get a runtime bug that only shows up in certain situations and whose detection is consequently dependent on having very good testing coverage. And then, assuming you detect it, you have to figure which method has the wrong logic in it.</p>
<p>If you don&#8217;t use the Null object pattern, there is a chance you will get NullPointerException, but that&#8217;s good because that means the application is fail-fast and you know exactly where you forget to do the check.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shunmuga</title>
		<link>http://www.redcode.nl/blog/2010/02/handling-null-in-java/comment-page-1/#comment-95</link>
		<dc:creator>shunmuga</dc:creator>
		<pubDate>Tue, 02 Feb 2010 15:44:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.redcode.nl/?p=340#comment-95</guid>
		<description>This is cool post dude nice article!!!</description>
		<content:encoded><![CDATA[<p>This is cool post dude nice article!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: royvanrijn</title>
		<link>http://www.redcode.nl/blog/2010/02/handling-null-in-java/comment-page-1/#comment-94</link>
		<dc:creator>royvanrijn</dc:creator>
		<pubDate>Tue, 02 Feb 2010 15:31:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.redcode.nl/?p=340#comment-94</guid>
		<description>Adding RuntimeExceptions for all input as check would take quite a bit of effort if you need to do this all over your code. That&#039;s why I still prefer code-by-contract.

Another (probably better) option would be to add assertions (&#039;assert&#039; keyword). That is exacly why they created them.</description>
		<content:encoded><![CDATA[<p>Adding RuntimeExceptions for all input as check would take quite a bit of effort if you need to do this all over your code. That&#8217;s why I still prefer code-by-contract.</p>
<p>Another (probably better) option would be to add assertions (&#8216;assert&#8217; keyword). That is exacly why they created them.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: phil swenson</title>
		<link>http://www.redcode.nl/blog/2010/02/handling-null-in-java/comment-page-1/#comment-93</link>
		<dc:creator>phil swenson</dc:creator>
		<pubDate>Tue, 02 Feb 2010 14:58:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.redcode.nl/?p=340#comment-93</guid>
		<description>Or....

if null is not a valid input (person being null is a bug),  first line in the method is 

throw new RuntimeException(&quot;person cannot be null!&quot;);</description>
		<content:encoded><![CDATA[<p>Or&#8230;.</p>
<p>if null is not a valid input (person being null is a bug),  first line in the method is </p>
<p>throw new RuntimeException(&#8220;person cannot be null!&#8221;);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christophe Hamerling</title>
		<link>http://www.redcode.nl/blog/2010/02/handling-null-in-java/comment-page-1/#comment-92</link>
		<dc:creator>Christophe Hamerling</dc:creator>
		<pubDate>Tue, 02 Feb 2010 13:38:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.redcode.nl/?p=340#comment-92</guid>
		<description>This is a really nice article, simple and very useful!</description>
		<content:encoded><![CDATA[<p>This is a really nice article, simple and very useful!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephan Schmidt</title>
		<link>http://www.redcode.nl/blog/2010/02/handling-null-in-java/comment-page-1/#comment-90</link>
		<dc:creator>Stephan Schmidt</dc:creator>
		<pubDate>Tue, 02 Feb 2010 10:27:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.redcode.nl/?p=340#comment-90</guid>
		<description>Nice post. You can also use the Option/Maybe monad.

I&#039;ve did a presentation on Null Handling some time ago, which also describes the Option monad.

http://codemonkeyism.com/better-null-handling-strategies-for-java/

And easier usage with the &quot;for&quot; hack in Java:

http://codemonkeyism.com/for-hack-with-option-monad-in-java/

Cheers
Stephan</description>
		<content:encoded><![CDATA[<p>Nice post. You can also use the Option/Maybe monad.</p>
<p>I&#8217;ve did a presentation on Null Handling some time ago, which also describes the Option monad.</p>
<p><a href="http://codemonkeyism.com/better-null-handling-strategies-for-java/" rel="nofollow">http://codemonkeyism.com/better-null-handling-strategies-for-java/</a></p>
<p>And easier usage with the &#8220;for&#8221; hack in Java:</p>
<p><a href="http://codemonkeyism.com/for-hack-with-option-monad-in-java/" rel="nofollow">http://codemonkeyism.com/for-hack-with-option-monad-in-java/</a></p>
<p>Cheers<br />
Stephan</p>
]]></content:encoded>
	</item>
</channel>
</rss>
