<?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>Professional PHP &#187; exceptions</title>
	<atom:link href="http://www.procata.com/blog/archives/tag/exceptions/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.procata.com/blog</link>
	<description>PHP Programming, Web Development, PHP Advocacy and PHP Best Practices.</description>
	<lastBuildDate>Fri, 10 Dec 2010 17:23:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Exceptional PHP</title>
		<link>http://www.procata.com/blog/archives/2004/05/24/exceptional-php/</link>
		<comments>http://www.procata.com/blog/archives/2004/05/24/exceptional-php/#comments</comments>
		<pubDate>Tue, 25 May 2004 04:06:07 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software Design]]></category>
		<category><![CDATA[exceptions]]></category>

		<guid isPermaLink="false">http://www.procata.com/blog/archives/2004/05/24/exceptional-php/</guid>
		<description><![CDATA[With PHP 5 adding exceptions, I imagine that the PHP community will have to undergo a bit of a paradigm change regarding PHP error handling.  This transition probably won&#8217;t be without controversy and heartache, especially for those integrating third party libraries.  I suspect that some of these issues won&#8217;t get worked out until [...]]]></description>
			<content:encoded><![CDATA[<p>With PHP 5 adding exceptions, I imagine that the PHP community will have to undergo a bit of a paradigm change regarding <a href="http://www.samspublishing.com/articles/article.asp?p=170279">PHP error handling</a>.  This transition probably won&#8217;t be without controversy and heartache, especially for those integrating third party libraries.  I suspect that some of these issues won&#8217;t get worked out until 5.1. </p>
<p>Wez Furlong has a proposal for <a href="http://netevil.org/node.php?nid=12">structured errors in PHP</a>.  I like the idea of standard error codes.  I don&#8217;t much care for the exception_map or the superglobal part, though.</p>
<p>Even languages that have had exceptions forever still have controversy over the issue.  Joel on Software <a href="http://www.joelonsoftware.com/items/2003/10/13.html">considers exceptions harmful</a> and favors status returns:</p>
<blockquote><p>A better alternative is to have your functions return error values when things go wrong, and to deal with these explicitly, no matter how verbose it might be. It is true that what should be a simple 3 line program often blossoms to 48 lines when you put in good error checking, but that&#8217;s life, and papering it over with exceptions does not make your program more robust.</p></blockquote>
<p>Doug Ross <a href="http://directorblue.blogspot.com/2004/05/return-codes-vs.html">agrees with Joel</a> and talks a bit about poor software quality.  It almost seems like he is elevating exceptions considered harmful into exceptions kill:</p>
<blockquote><p>In other words, many of us are undisciplined. We&#8217;re more worried about &#8220;readability&#8221; (and I disagree with that contention as well &#8211; but I&#8217;ll get to that) than whether or not or software will kill anyone, debit the wrong account by a million bucks, or screw up the actuarial table for 83 year-old transvestites.</p></blockquote>
<p>I agree with Ned Batchelder&#8217;s comprehensive rebuttal in <a href="http://www.nedbatchelder.com/text/exceptions-vs-status.html">exceptions vs status returns</a>.  Bob Balaban comments on this with an anecdote:</p>
<blockquote><p>Years ago at Lotus one of the architects did an actual benchmark of some code in 123 written first with the status technique and then with the exception technique, and claimed that the exception technique was 15% less code (he was comparing compiled code size) and maybe 5% faster.</p></blockquote>
<p>Following my <a href="http://www.procata.com/blog/archives/2004/05/05/api-design/">API Design principles</a>, I think the smallest amount of code wins.  If exceptions can reduce the amount of code, then that is the best way to go.  After all, error propagation code can have errors too.  Code verbosity considered harmful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.procata.com/blog/archives/2004/05/24/exceptional-php/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

