<?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: How to Handle Null Values in Code</title>
	<atom:link href="http://www.basilv.com/psd/blog/2008/how-to-handle-null-values-in-code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.basilv.com/psd/blog/2008/how-to-handle-null-values-in-code</link>
	<description></description>
	<lastBuildDate>Wed, 08 Feb 2012 03:57:22 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
	<item>
		<title>By: Ewald</title>
		<link>http://www.basilv.com/psd/blog/2008/how-to-handle-null-values-in-code/comment-page-1#comment-104650</link>
		<dc:creator>Ewald</dc:creator>
		<pubDate>Wed, 24 Feb 2010 07:21:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.basilv.com/psd/blog/2008/how-to-handle-null-values-in-code#comment-104650</guid>
		<description>I am very glad I found your website on reddit. Thank you for the sensible critique. Me and my brother were just preparing to do some research about this. I am glad to see such reliable information being shared for free out there.
Best Regards,
Burton from Columbus city (remainder)</description>
		<content:encoded><![CDATA[<p>I am very glad I found your website on reddit. Thank you for the sensible critique. Me and my brother were just preparing to do some research about this. I am glad to see such reliable information being shared for free out there.<br />
Best Regards,<br />
Burton from Columbus city (remainder)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Wilden</title>
		<link>http://www.basilv.com/psd/blog/2008/how-to-handle-null-values-in-code/comment-page-1#comment-42521</link>
		<dc:creator>Mark Wilden</dc:creator>
		<pubDate>Sat, 16 Feb 2008 03:28:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.basilv.com/psd/blog/2008/how-to-handle-null-values-in-code#comment-42521</guid>
		<description>In C#, the &#039;int&#039; type is not nullable, but the &#039;int?&#039; type is.

///ark</description>
		<content:encoded><![CDATA[<p>In C#, the &#8216;int&#8217; type is not nullable, but the &#8216;int?&#8217; type is.</p>
<p>///ark</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: the_Tzar</title>
		<link>http://www.basilv.com/psd/blog/2008/how-to-handle-null-values-in-code/comment-page-1#comment-42049</link>
		<dc:creator>the_Tzar</dc:creator>
		<pubDate>Thu, 14 Feb 2008 06:58:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.basilv.com/psd/blog/2008/how-to-handle-null-values-in-code#comment-42049</guid>
		<description>While writing an application that had to parse through a lot of binary data, I used assertions a lot. It allowed me to be very restrictive during development and to be very fault tolerant during deployment.
Let&#039;s face it, if I miss one character or if I get some metedata about textcolor wrong, I want to know during development, but I want to ignore it during deployment.
So yes, assertions can be turned off and I expect them to be turned off.
For nullpointers, what use is it to replace a NullpointerException by a IllegalArgumentException or an AsserionError. It all stopts your programm anyway and with good tooling you&#039;ll know why allmost imidiately.</description>
		<content:encoded><![CDATA[<p>While writing an application that had to parse through a lot of binary data, I used assertions a lot. It allowed me to be very restrictive during development and to be very fault tolerant during deployment.<br />
Let&#8217;s face it, if I miss one character or if I get some metedata about textcolor wrong, I want to know during development, but I want to ignore it during deployment.<br />
So yes, assertions can be turned off and I expect them to be turned off.<br />
For nullpointers, what use is it to replace a NullpointerException by a IllegalArgumentException or an AsserionError. It all stopts your programm anyway and with good tooling you&#8217;ll know why allmost imidiately.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: el gregorio</title>
		<link>http://www.basilv.com/psd/blog/2008/how-to-handle-null-values-in-code/comment-page-1#comment-41934</link>
		<dc:creator>el gregorio</dc:creator>
		<pubDate>Wed, 13 Feb 2008 16:34:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.basilv.com/psd/blog/2008/how-to-handle-null-values-in-code#comment-41934</guid>
		<description>Sun documentation at http://java.sun.com/j2se/1.4.2/docs/guide/lang/assert.html states, 

&quot;Do not use assertions for argument checking in public methods.

Argument checking is typically part of the published specifications (or contract) of a method, and these specifications must be obeyed whether assertions are enabled or disabled. Another problem with using assertions for argument checking is that erroneous arguments should result in an appropriate runtime exception (such as IllegalArgumentException, IndexOutOfBoundsException, or NullPointerException). An assertion failure will not throw an appropriate exception. &quot;</description>
		<content:encoded><![CDATA[<p>Sun documentation at <a href="http://java.sun.com/j2se/1.4.2/docs/guide/lang/assert.html" rel="nofollow">http://java.sun.com/j2se/1.4.2/docs/guide/lang/assert.html</a> states, </p>
<p>&#8220;Do not use assertions for argument checking in public methods.</p>
<p>Argument checking is typically part of the published specifications (or contract) of a method, and these specifications must be obeyed whether assertions are enabled or disabled. Another problem with using assertions for argument checking is that erroneous arguments should result in an appropriate runtime exception (such as IllegalArgumentException, IndexOutOfBoundsException, or NullPointerException). An assertion failure will not throw an appropriate exception. &#8220;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Basil Vandegriend</title>
		<link>http://www.basilv.com/psd/blog/2008/how-to-handle-null-values-in-code/comment-page-1#comment-41912</link>
		<dc:creator>Basil Vandegriend</dc:creator>
		<pubDate>Wed, 13 Feb 2008 13:38:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.basilv.com/psd/blog/2008/how-to-handle-null-values-in-code#comment-41912</guid>
		<description>Thanks Peter and Kit for mentioning the Groovy &#039;?&#039; notation. I wasn&#039;t aware of it, and think it is a nice, concise syntax. 

I&#039;m not sure I like having a @NotNull annotation in Java - it seems a little clunky (i.e. too verbose) compared to my syntax suggestion. It does have the advantage of not changing the syntax of the language, so I suppose it is more likely such an approach would eventually be adopted.

Considering the bigger picture, the fact that languages, especially more recent ones, are adding special syntax for handling nulls or for supporting nullable types shows that this is an important issue.</description>
		<content:encoded><![CDATA[<p>Thanks Peter and Kit for mentioning the Groovy &#8216;?&#8217; notation. I wasn&#8217;t aware of it, and think it is a nice, concise syntax. </p>
<p>I&#8217;m not sure I like having a @NotNull annotation in Java &#8211; it seems a little clunky (i.e. too verbose) compared to my syntax suggestion. It does have the advantage of not changing the syntax of the language, so I suppose it is more likely such an approach would eventually be adopted.</p>
<p>Considering the bigger picture, the fact that languages, especially more recent ones, are adding special syntax for handling nulls or for supporting nullable types shows that this is an important issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ivan Memruk</title>
		<link>http://www.basilv.com/psd/blog/2008/how-to-handle-null-values-in-code/comment-page-1#comment-41911</link>
		<dc:creator>Ivan Memruk</dc:creator>
		<pubDate>Wed, 13 Feb 2008 13:35:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.basilv.com/psd/blog/2008/how-to-handle-null-values-in-code#comment-41911</guid>
		<description>You can use a method parameter annotation and wrap your classes into AOP proxies. The OVal validation framework does that. That way you will both express your constraints efficiently and not add any imperative noise into the code.

You also don&#039;t need to change Java this way.</description>
		<content:encoded><![CDATA[<p>You can use a method parameter annotation and wrap your classes into AOP proxies. The OVal validation framework does that. That way you will both express your constraints efficiently and not add any imperative noise into the code.</p>
<p>You also don&#8217;t need to change Java this way.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kit Davies</title>
		<link>http://www.basilv.com/psd/blog/2008/how-to-handle-null-values-in-code/comment-page-1#comment-41897</link>
		<dc:creator>Kit Davies</dc:creator>
		<pubDate>Wed, 13 Feb 2008 12:33:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.basilv.com/psd/blog/2008/how-to-handle-null-values-in-code#comment-41897</guid>
		<description>When/if we get java closures, a nice option could be something like:

asserting(customer != null) {
  List orders = customer.getOrders();
  asserting(orders != null) {
    for(order : orders) {
      ...
    }
  }
}

Then you get fail-fast and degrade-gracefully in a fairly
readable format.

BTW, Groovy has a &#039;?&#039; notation for handling nulls. So:

customer?.orders?.itemAt(1)

would return null if either customer or orders were null.

Kit</description>
		<content:encoded><![CDATA[<p>When/if we get java closures, a nice option could be something like:</p>
<p>asserting(customer != null) {<br />
  List orders = customer.getOrders();<br />
  asserting(orders != null) {<br />
    for(order : orders) {<br />
      &#8230;<br />
    }<br />
  }<br />
}</p>
<p>Then you get fail-fast and degrade-gracefully in a fairly<br />
readable format.</p>
<p>BTW, Groovy has a &#8216;?&#8217; notation for handling nulls. So:</p>
<p>customer?.orders?.itemAt(1)</p>
<p>would return null if either customer or orders were null.</p>
<p>Kit</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Maas</title>
		<link>http://www.basilv.com/psd/blog/2008/how-to-handle-null-values-in-code/comment-page-1#comment-41894</link>
		<dc:creator>Peter Maas</dc:creator>
		<pubDate>Wed, 13 Feb 2008 12:18:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.basilv.com/psd/blog/2008/how-to-handle-null-values-in-code#comment-41894</guid>
		<description>Slightly on topic:

In Groovy there is something called a safe dereference operator:


customer?.getOrders().each{ it -&gt;
  ...
}


The getOrders method on customer won&#039;t be called if customer is null.</description>
		<content:encoded><![CDATA[<p>Slightly on topic:</p>
<p>In Groovy there is something called a safe dereference operator:</p>
<p>customer?.getOrders().each{ it -&gt;<br />
  &#8230;<br />
}</p>
<p>The getOrders method on customer won&#8217;t be called if customer is null.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Casper Bang</title>
		<link>http://www.basilv.com/psd/blog/2008/how-to-handle-null-values-in-code/comment-page-1#comment-41891</link>
		<dc:creator>Casper Bang</dc:creator>
		<pubDate>Wed, 13 Feb 2008 12:01:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.basilv.com/psd/blog/2008/how-to-handle-null-values-in-code#comment-41891</guid>
		<description>Clearly, null checking leaves you with the feeling that... it would be better if you could leave it out. But I think you are comparing apples and oranges. Asserts represents logical errors, faulty states in the application which are never permitted. Yet real life is often much more messy than we would like where you often potentially have to expect null as part of the normal control flow. Of course C# handles this a little better than Java, in that you have nullable types and static analysis tools will be able to deduce much more about your code than in Java. I seeem to remember Brian Goetz prototyping support for a @NotNull annotations for roughly the same purpose.</description>
		<content:encoded><![CDATA[<p>Clearly, null checking leaves you with the feeling that&#8230; it would be better if you could leave it out. But I think you are comparing apples and oranges. Asserts represents logical errors, faulty states in the application which are never permitted. Yet real life is often much more messy than we would like where you often potentially have to expect null as part of the normal control flow. Of course C# handles this a little better than Java, in that you have nullable types and static analysis tools will be able to deduce much more about your code than in Java. I seeem to remember Brian Goetz prototyping support for a @NotNull annotations for roughly the same purpose.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: anonymous</title>
		<link>http://www.basilv.com/psd/blog/2008/how-to-handle-null-values-in-code/comment-page-1#comment-41887</link>
		<dc:creator>anonymous</dc:creator>
		<pubDate>Wed, 13 Feb 2008 11:44:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.basilv.com/psd/blog/2008/how-to-handle-null-values-in-code#comment-41887</guid>
		<description>You should also consider to use the @NotNull annotation to mark parameters that shouldn&#039;t be null.</description>
		<content:encoded><![CDATA[<p>You should also consider to use the @NotNull annotation to mark parameters that shouldn&#8217;t be null.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

