<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>./cmsimike &#187; mistake</title>
	<atom:link href="http://www.cmsimike.com/blog/tag/mistake/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cmsimike.com/blog</link>
	<description>thoughts from a computer scientist</description>
	<lastBuildDate>Sun, 08 Jan 2012 22:20:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>On the Subjects of object == null and collection.size() == 0</title>
		<link>http://www.cmsimike.com/blog/2009/07/28/on-the-subject-of-object-is-null-and-collection-size-equals-0/</link>
		<comments>http://www.cmsimike.com/blog/2009/07/28/on-the-subject-of-object-is-null-and-collection-size-equals-0/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 20:38:12 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[education]]></category>
		<category><![CDATA[mistake]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[software engineering]]></category>

		<guid isPermaLink="false">http://www.cmsimike.com/blog/?p=161</guid>
		<description><![CDATA[Let&#8217;s just get one thing straight here people, an object that is null does not mean the same thing as a collection/array of length zero. I&#8217;m sort of seeing this more and more as I continue my existence on this planet and I say we put a stop to this now. Take this example method [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s just get one thing straight here people, an object that is null does not mean the same thing as a collection/array of length zero. I&#8217;m sort of seeing this more and more as I continue my existence on this planet and I say we put a stop to this now. Take this example method declaration (written in Java):</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> Collection<span style="color: #339933;">&lt;</span>SearchResult<span style="color: #339933;">&gt;</span> getSearchResults<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> searchTerm<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Straight forward enough, I would hope. This method takes in a searchTerm String, magic happens (ah abstraction), and a Collection of type SearchResult is returned. Now here is the kicker: what happens if the search query resulted in no results? What should be returned? And why?</p>
<p><span id="more-161"></span></p>
<p>At this point, we essentially have two options if we want to successfully return from this method without using exceptions: return null or return a Collection of type SearchResult of size n | n >= 0;</p>
<p>When returning a Collection, the size indicates how many SearchResults there were. If someone were to search for &#8220;cows&#8221; and the Collection contained 23 SearchResult objects, then we should say that the search had 23 results. Contrary to that, if there are 0 SearchResult objects then we can say that the search had no results.</p>
<p>When null is returned instead of a Collection, that can only mean that something has gone wrong. For instance, the search could not be completed for any reason. This should be the only reason a null should be returned. </p>
<p>By returning a null if a search has been successfully completed, even if there are no results, tells the caller that there may have been an error, which is not what you want to communicate. Returning null should be the worst case scenario in a circumstance like this. It is the duty of the implementer of the getSearchResults method to fully communicate the actual status of things by returning what is the most correct in any situation. </p>
<p>Please do not return null lightly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cmsimike.com/blog/2009/07/28/on-the-subject-of-object-is-null-and-collection-size-equals-0/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Best Buy Strikes Again with Brilliant Advertising</title>
		<link>http://www.cmsimike.com/blog/2008/09/09/best-buy-strikes-again-with-brilliant-advertising/</link>
		<comments>http://www.cmsimike.com/blog/2008/09/09/best-buy-strikes-again-with-brilliant-advertising/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 21:14:56 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[advertising]]></category>
		<category><![CDATA[bestbuy]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[mistake]]></category>

		<guid isPermaLink="false">http://www.cmsimike.com/blog/2008/09/09/bestbuy-strikea-again/</guid>
		<description><![CDATA[Ok Best Buy I&#8217;m sold. Where can I get a iPhone 3GB? 8GB and 16GB are just way too much for me.

]]></description>
			<content:encoded><![CDATA[<p>Ok Best Buy I&#8217;m sold. Where can I get a iPhone 3GB? 8GB and 16GB are just way too much for me.</p>
<p><a href="http://www.cmsimike.com/blog/wp-content/uploads/2008/09/p-640-480-847d0047-d362-464b-9713-87a9e5c1edd3.jpeg"><img class="alignnone size-full wp-image-364" src="http://www.cmsimike.com/blog/wp-content/uploads/2008/09/p-640-480-847d0047-d362-464b-9713-87a9e5c1edd3.jpeg" alt="" width="225" height="300" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cmsimike.com/blog/2008/09/09/best-buy-strikes-again-with-brilliant-advertising/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>No Final Fantasy 7 Rerelease on the Playstation 3 for 2008-08-16</title>
		<link>http://www.cmsimike.com/blog/2008/08/16/no-final-fantasy-7-rerelease-on-the-playstation-3-for-2008-08-16/</link>
		<comments>http://www.cmsimike.com/blog/2008/08/16/no-final-fantasy-7-rerelease-on-the-playstation-3-for-2008-08-16/#comments</comments>
		<pubDate>Sat, 16 Aug 2008 20:22:06 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[advertising]]></category>
		<category><![CDATA[final fantasy]]></category>
		<category><![CDATA[mistake]]></category>
		<category><![CDATA[sad news]]></category>
		<category><![CDATA[video games]]></category>
		<category><![CDATA[wrong]]></category>

		<guid isPermaLink="false">http://www.cmsimike.com/blog/?p=40</guid>
		<description><![CDATA[In response to: http://www.cmsimike.com/blog/2008/08/14/final-fantasy-7-release-on-the-playstation-3/
It is with a sad and heavy heart that I report that there doesn&#8217;t seem to be a Final Fantasy 7 release for the Playstation 3 today. Not at the Best Buy in Pasadena anyway. Seems like the internet was right once again. And, in a way, I didn&#8217;t think it would [...]]]></description>
			<content:encoded><![CDATA[<p>In response to: http://www.cmsimike.com/blog/2008/08/14/final-fantasy-7-release-on-the-playstation-3/</p>
<p>It is with a sad and heavy heart that I report that there doesn&#8217;t seem to be a Final Fantasy 7 release for the Playstation 3 today. Not at the Best Buy in Pasadena anyway. Seems like the <a title="FF7 Remake" href="http://www.psu.com/Best-Buy-advertising-FFVII-for-the-PlayStation-3-News--a0004430-p0.php" target="_blank">internet</a> <a title="FF7 Remake" href="http://kotaku.com/5032652/best-buy-advertising-final-fantasy-vii-ps3" target="_blank">was</a> <a title="FF7 Remake" href="http://www.finalfantasyseries.net/final-fantasy-vii-ps3-version-releasing-16th-august" target="_blank">right</a> once again. And, in a way, I didn&#8217;t think it would happen either. I just had some hope. Hope that is now crushed.</p>
<p>If you need me, I will be in the corner sulking and watching <a title="Spaced" href="http://en.wikipedia.org/wiki/Spaced" target="_blank">Spaced</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cmsimike.com/blog/2008/08/16/no-final-fantasy-7-rerelease-on-the-playstation-3-for-2008-08-16/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

