<?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: Null Handling Strategies</title>
	<atom:link href="http://www.markhneedham.com/blog/2008/08/16/null-handling-strategies/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.markhneedham.com/blog/2008/08/16/null-handling-strategies/</link>
	<description>Thoughts on Software Development</description>
	<lastBuildDate>Wed, 17 Mar 2010 23:38:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Arcard</title>
		<link>http://www.markhneedham.com/blog/2008/08/16/null-handling-strategies/comment-page-1/#comment-882</link>
		<dc:creator>Arcard</dc:creator>
		<pubDate>Thu, 23 Oct 2008 18:05:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=135#comment-882</guid>
		<description>Занимаюсь дизайном и хочу попросить автора blog.kriskemper.com отправить шаьлончик на мой мыил) Готов заплатить...</description>
		<content:encoded><![CDATA[<p>Занимаюсь дизайном и хочу попросить автора blog.kriskemper.com отправить шаьлончик на мой мыил) Готов заплатить&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: unlIche</title>
		<link>http://www.markhneedham.com/blog/2008/08/16/null-handling-strategies/comment-page-1/#comment-644</link>
		<dc:creator>unlIche</dc:creator>
		<pubDate>Tue, 07 Oct 2008 23:26:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=135#comment-644</guid>
		<description>Подскажите шооблончег  под Wordpress 2.6.2, чтобы был похож на ваш blog.kriskemper.com.

Заранее благодарю)</description>
		<content:encoded><![CDATA[<p>Подскажите шооблончег  под Wordpress 2.6.2, чтобы был похож на ваш blog.kriskemper.com.</p>
<p>Заранее благодарю)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Kirby</title>
		<link>http://www.markhneedham.com/blog/2008/08/16/null-handling-strategies/comment-page-1/#comment-40</link>
		<dc:creator>Dave Kirby</dc:creator>
		<pubDate>Tue, 19 Aug 2008 11:49:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=135#comment-40</guid>
		<description>An alternative is to give the caller the choice.

An example is the Python dictionary data type.  This lets you access elements in two ways.  Firstly you can use the [] syntax, which raises an exception if the element is not in the dictionary.  Secondly you can do it via the get method which lets you specify a default value to be returned, and the default value defaults to None (the Python equivalent of null) if it is not specified.

i.e.

d = {}  # create an empty dictionary

d[&#039;foo&#039;]  # raises KeyError

d.get(&#039;foo&#039;) # returns None

d.get(&#039;foo&#039;, &#039;something&#039;) # returns &#039;something&#039;</description>
		<content:encoded><![CDATA[<p>An alternative is to give the caller the choice.</p>
<p>An example is the Python dictionary data type.  This lets you access elements in two ways.  Firstly you can use the [] syntax, which raises an exception if the element is not in the dictionary.  Secondly you can do it via the get method which lets you specify a default value to be returned, and the default value defaults to None (the Python equivalent of null) if it is not specified.</p>
<p>i.e.</p>
<p>d = {}  # create an empty dictionary</p>
<p>d['foo']  # raises KeyError</p>
<p>d.get('foo') # returns None</p>
<p>d.get('foo', 'something') # returns 'something'</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bernd Eckenfels</title>
		<link>http://www.markhneedham.com/blog/2008/08/16/null-handling-strategies/comment-page-1/#comment-36</link>
		<dc:creator>Bernd Eckenfels</dc:creator>
		<pubDate>Sat, 16 Aug 2008 12:34:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=135#comment-36</guid>
		<description>Returning null in a case where no result (excpet empty collections) can be expected is quite tollerable for me. However returning null for error cases where nobody expects null returns (for example in factoriey) is dangerous.

I have the rule to require code to state &quot;return null;&quot; in the code and a comment in javadoc when it wants to signal something, and it should never return a variable which can eventually be null.

Blogged about this in german here: http://itblog.eckenfels.net/archives/352-Null-returns-in-Java.html</description>
		<content:encoded><![CDATA[<p>Returning null in a case where no result (excpet empty collections) can be expected is quite tollerable for me. However returning null for error cases where nobody expects null returns (for example in factoriey) is dangerous.</p>
<p>I have the rule to require code to state "return null;" in the code and a comment in javadoc when it wants to signal something, and it should never return a variable which can eventually be null.</p>
<p>Blogged about this in german here: <a href="http://itblog.eckenfels.net/archives/352-Null-returns-in-Java.html" rel="nofollow">http://itblog.eckenfels.net/archives/352-Null-returns-in-Java.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aaron Erickson</title>
		<link>http://www.markhneedham.com/blog/2008/08/16/null-handling-strategies/comment-page-1/#comment-32</link>
		<dc:creator>Aaron Erickson</dc:creator>
		<pubDate>Sat, 16 Aug 2008 03:33:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=135#comment-32</guid>
		<description>The thing I dont like about solution 2 is that you are using an exception for an unexceptional condition - i.e. many people who live in places like Manhattan, or Wicker Park, dont have cars ;)

That, and we are drilled in our heads as CompSci students that null is a possible condition of every object.  That said, some spec that you can put on methods that will at least tell you if a null is possible is a good idea - at least for compile checking to assure that you handle null if that is a possible condition.

That all said, from a design standpoint, null is a PITA.  Would rather avoid it where possible - not having it makes things simpler, all things being equal.</description>
		<content:encoded><![CDATA[<p>The thing I dont like about solution 2 is that you are using an exception for an unexceptional condition &#8211; i.e. many people who live in places like Manhattan, or Wicker Park, dont have cars <img src='http://www.markhneedham.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>That, and we are drilled in our heads as CompSci students that null is a possible condition of every object.  That said, some spec that you can put on methods that will at least tell you if a null is possible is a good idea &#8211; at least for compile checking to assure that you handle null if that is a possible condition.</p>
<p>That all said, from a design standpoint, null is a PITA.  Would rather avoid it where possible &#8211; not having it makes things simpler, all things being equal.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: The Sloth</title>
		<link>http://www.markhneedham.com/blog/2008/08/16/null-handling-strategies/comment-page-1/#comment-31</link>
		<dc:creator>The Sloth</dc:creator>
		<pubDate>Sat, 16 Aug 2008 03:26:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.markhneedham.com/blog/?p=135#comment-31</guid>
		<description>I would say that your gut feeling was right - NULL is a way to go except the case when you expect a colleciton - then empty collection is a right solution.
Exception will require much more efforts to produce and handle. Also try-catch is a quite expensive operation.
Null object is a classic case of overengineering - you wouldn&#039;t need it unless you&#039;re already employing few Strategy objects.
There is cleaner Null solution (Resharper catches it perfectly :)
Car car = carRepository.RetrieveCar(carId)
if(car == null) return;
car.Drive();

All other methods will result in much more hassle.</description>
		<content:encoded><![CDATA[<p>I would say that your gut feeling was right &#8211; NULL is a way to go except the case when you expect a colleciton &#8211; then empty collection is a right solution.<br />
Exception will require much more efforts to produce and handle. Also try-catch is a quite expensive operation.<br />
Null object is a classic case of overengineering &#8211; you wouldn't need it unless you're already employing few Strategy objects.<br />
There is cleaner Null solution (Resharper catches it perfectly <img src='http://www.markhneedham.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Car car = carRepository.RetrieveCar(carId)<br />
if(car == null) return;<br />
car.Drive();</p>
<p>All other methods will result in much more hassle.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
