<?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>Pretzel Wisdom &#187; Programming</title>
	<atom:link href="http://www.pretzelwisdom.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pretzelwisdom.com</link>
	<description>This space left intentionally blank?</description>
	<lastBuildDate>Fri, 07 May 2010 02:29:19 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Samurai Principle</title>
		<link>http://www.pretzelwisdom.com/2008/09/samurai-principle/</link>
		<comments>http://www.pretzelwisdom.com/2008/09/samurai-principle/#comments</comments>
		<pubDate>Mon, 29 Sep 2008 06:28:09 +0000</pubDate>
		<dc:creator>itay</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.pretzelwisdom.com/?p=10</guid>
		<description><![CDATA[I came across an interesting discussion on programming.reddit (the original link and the resulting discussion) about whether or not to use status code as return values to indicate success/failure, as opposed to using exceptions to indicate, well, exceptional cases.
I won&#8217;t repeat the pros and cons of either approach, as smarter people than me have done [...]]]></description>
			<content:encoded><![CDATA[<p>I came across an interesting discussion on programming.reddit (the <a href="http://binstock.blogspot.com/2008/09/banishing-return-status-codes.html">original link</a> and the <a href="http://www.reddit.com/r/programming/comments/7434k/stop_returning_status_codes_from_methods_please/">resulting discussion</a>) about whether or not to use status code as return values to indicate success/failure, as opposed to using exceptions to indicate, well, exceptional cases.</p>
<p>I won&#8217;t repeat the pros and cons of either approach, as smarter people than me have done so. One reason for using status codes that I didn&#8217;t see mentioned is the ability to easily identify non-failing functions. Imagine you see the following interface:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">Status DoThing1<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Status DoThing2<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Void   DoThing3<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>By observation, you immediately know that the third function simply cannot fail, and no error-checking need be done. The counter argument is of course that if the function declares an exception then you have the same information, but as someone else said, where checked exceptions lie, so do <a href="http://www.artima.com/intv/handcuffs.html">dragons</a>.</p>
<p>As to the title of this post, it was something new that I learnt today about something called the <b>Samurai Principle</b>:</p>
<blockquote><p>Return Victoriously, or not at all.</p></blockquote>
<p>That made my day.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pretzelwisdom.com/2008/09/samurai-principle/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
