<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: There more to consider than whether to return null</title>
	<link>http://blog.kriskemper.com/2008/08/19/there-more-to-consider-than-whether-to-return-null/</link>
	<description>Thoughtworker, Agile Philosopher, Hero</description>
	<pubDate>Thu, 11 Mar 2010 23:10:41 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.2</generator>
		<item>
		<title>By: sandrar</title>
		<link>http://blog.kriskemper.com/2008/08/19/there-more-to-consider-than-whether-to-return-null/#comment-7394</link>
		<dc:creator>sandrar</dc:creator>
		<pubDate>Thu, 10 Sep 2009 14:03:28 +0000</pubDate>
		<guid>http://blog.kriskemper.com/2008/08/19/there-more-to-consider-than-whether-to-return-null/#comment-7394</guid>
		<description>Hi! I was surfing and found your blog post... nice! I love your blog.  :) Cheers! Sandra. R.</description>
		<content:encoded><![CDATA[<p>Hi! I was surfing and found your blog post&#8230; nice! I love your blog.  <img src='http://blog.kriskemper.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> Cheers! Sandra. R.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anders</title>
		<link>http://blog.kriskemper.com/2008/08/19/there-more-to-consider-than-whether-to-return-null/#comment-813</link>
		<dc:creator>Anders</dc:creator>
		<pubDate>Tue, 07 Oct 2008 13:08:10 +0000</pubDate>
		<guid>http://blog.kriskemper.com/2008/08/19/there-more-to-consider-than-whether-to-return-null/#comment-813</guid>
		<description>Hi Kris,

I personally use the Drink.NULL or Drink.NONE or whatever pattern.

Because returning a Drink object instead of null means that usually I don't need to check post conditions and certainly not immediately on return. If, on the other hand, it really is bad that no non-null Drink could be returned an exception is required.

Drink.NULL just needs to have a reasonable toString() etc. and in general behave like a Drink.

-Anders</description>
		<content:encoded><![CDATA[<p>Hi Kris,</p>
<p>I personally use the Drink.NULL or Drink.NONE or whatever pattern.</p>
<p>Because returning a Drink object instead of null means that usually I don&#8217;t need to check post conditions and certainly not immediately on return. If, on the other hand, it really is bad that no non-null Drink could be returned an exception is required.</p>
<p>Drink.NULL just needs to have a reasonable toString() etc. and in general behave like a Drink.</p>
<p>-Anders</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kris Kemper</title>
		<link>http://blog.kriskemper.com/2008/08/19/there-more-to-consider-than-whether-to-return-null/#comment-299</link>
		<dc:creator>Kris Kemper</dc:creator>
		<pubDate>Wed, 20 Aug 2008 13:07:48 +0000</pubDate>
		<guid>http://blog.kriskemper.com/2008/08/19/there-more-to-consider-than-whether-to-return-null/#comment-299</guid>
		<description>@Bill

I've seen Null object pattern versions of Value Objects before (ie: Money, Date, etc). You have a isNull method in the case that you want to ask whether or not you have a value. For instance, there may not be an acceptable default value for a Date, so you can't prevent it from being null. The NullDate class would return true for isNull so I can detect that. Interally, it'll just be doing a "return value == null"

@Bernd

I agree, the precondition approach has it's issues - I favor it because of it's readability and simplicity. As far as preparing for the abuse of the api - well, that's an issue with having a getDrink() method at all.</description>
		<content:encoded><![CDATA[<p>@Bill</p>
<p>I&#8217;ve seen Null object pattern versions of Value Objects before (ie: Money, Date, etc). You have a isNull method in the case that you want to ask whether or not you have a value. For instance, there may not be an acceptable default value for a Date, so you can&#8217;t prevent it from being null. The NullDate class would return true for isNull so I can detect that. Interally, it&#8217;ll just be doing a &#8220;return value == null&#8221;</p>
<p>@Bernd</p>
<p>I agree, the precondition approach has it&#8217;s issues - I favor it because of it&#8217;s readability and simplicity. As far as preparing for the abuse of the api - well, that&#8217;s an issue with having a getDrink() method at all.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bernd Eckenfels</title>
		<link>http://blog.kriskemper.com/2008/08/19/there-more-to-consider-than-whether-to-return-null/#comment-297</link>
		<dc:creator>Bernd Eckenfels</dc:creator>
		<pubDate>Wed, 20 Aug 2008 11:02:29 +0000</pubDate>
		<guid>http://blog.kriskemper.com/2008/08/19/there-more-to-consider-than-whether-to-return-null/#comment-297</guid>
		<description>The pre-condition case has two problems (however I still think it is usefull):

a) you still need to prepare for abusive usage of the API - i.e. somebody is calling getDrink() without checking the money, the operating temperature, the maintance state (and other) preconditions.

b) in a multi threaded environment some moethods tends to be atomic so you do not have to hold a lock over multiple invocations. In this scenario a pre condition check might not be valid anymore unti you get to the getter. Somebody stolen your can.</description>
		<content:encoded><![CDATA[<p>The pre-condition case has two problems (however I still think it is usefull):</p>
<p>a) you still need to prepare for abusive usage of the API - i.e. somebody is calling getDrink() without checking the money, the operating temperature, the maintance state (and other) preconditions.</p>
<p>b) in a multi threaded environment some moethods tends to be atomic so you do not have to hold a lock over multiple invocations. In this scenario a pre condition check might not be valid anymore unti you get to the getter. Somebody stolen your can.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bill Comer</title>
		<link>http://blog.kriskemper.com/2008/08/19/there-more-to-consider-than-whether-to-return-null/#comment-296</link>
		<dc:creator>Bill Comer</dc:creator>
		<pubDate>Wed, 20 Aug 2008 08:50:41 +0000</pubDate>
		<guid>http://blog.kriskemper.com/2008/08/19/there-more-to-consider-than-whether-to-return-null/#comment-296</guid>
		<description>Kris,

Slightly off topic but please could you expand on the code behind the isNull() method.

Thx.
Bill</description>
		<content:encoded><![CDATA[<p>Kris,</p>
<p>Slightly off topic but please could you expand on the code behind the isNull() method.</p>
<p>Thx.<br />
Bill</p>
]]></content:encoded>
	</item>
</channel>
</rss>
