<?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>Way of the Spatula &#187; programming</title>
	<atom:link href="http://barbecueguy.com/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://barbecueguy.com</link>
	<description>barbecueguy.com</description>
	<lastBuildDate>Fri, 18 Mar 2011 04:19:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>PHP trials and tribulations</title>
		<link>http://barbecueguy.com/2007/05/23/php-trials-and-tribulations/</link>
		<comments>http://barbecueguy.com/2007/05/23/php-trials-and-tribulations/#comments</comments>
		<pubDate>Wed, 23 May 2007 08:53:00 +0000</pubDate>
		<dc:creator>John Kraft</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://barbecueguy.com/?p=333</guid>
		<description><![CDATA[I&#8217;m convinced that PHP is the bastard love child of C and Perl.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m convinced that PHP is the bastard love child of C and Perl.</p>
]]></content:encoded>
			<wfw:commentRss>http://barbecueguy.com/2007/05/23/php-trials-and-tribulations/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>I love infinite recursion!</title>
		<link>http://barbecueguy.com/2006/05/10/i-love-infinite-recursion/</link>
		<comments>http://barbecueguy.com/2006/05/10/i-love-infinite-recursion/#comments</comments>
		<pubDate>Wed, 10 May 2006 23:51:00 +0000</pubDate>
		<dc:creator>John Kraft</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://barbecueguy.com/?p=277</guid>
		<description><![CDATA[Today at work, I came across some interesting code. I looked at it for quite some time before it occurred to me what was wrong with it. Below is a simplified synopsis of the code. The following code uses a database query I will call Q and a boolean function I will call F. function [...]]]></description>
			<content:encoded><![CDATA[<p>Today at work, I came across some interesting code.  I looked at it for quite some time before it occurred to me what was wrong with it.  Below is a simplified synopsis of the code.  </p>
<p>The following code uses a database query I will call Q and a boolean function I will call F.</p>
<p><code></p>
<p>function F(): boolean;<br />
&nbsp;begin<br />
&nbsp;&nbsp;try<br />
&nbsp;&nbsp;&nbsp;if (Q.Active) then<br />
&nbsp;&nbsp;&nbsp;&nbsp;begin<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// do some stuff<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result := true;<br />
&nbsp;&nbsp;&nbsp;&nbsp;end<br />
&nbsp;&nbsp;&nbsp;else<br />
&nbsp;&nbsp;&nbsp;&nbsp;begin<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;result := false;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ErrorMessage := 'No results found';<br />
&nbsp;&nbsp;&nbsp;&nbsp;end;<br />
&nbsp;&nbsp;&nbsp;except<br />
&nbsp;&nbsp;&nbsp;&nbsp;on e: Exception do<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Q.Close();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Q.Open();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br />
&nbsp;&nbsp;&nbsp;end;<br />
&nbsp;&nbsp;end;</p>
<p>//<br />
// Main method<br />
//</p>
<p>Q.Open();<br />
F();</p>
<p></code></p>
<p>If you can&#8217;t see the problem, it was really twofold.  First, god help you if an exception gets thrown.  If so, you could go into an infinite recursion loop if the issue was an error occuring on the database side.  Second, if the connection cannot be opened, the function would return false and tell the user that there were no results in the database.  In truth, there very well could be a million results and the function would effectively be lying.  Although the code isn&#8217;t horribly written stylewise, I cannot believe someone would do something like this.  It absolutely amazes me.  </p>
<p>The first problem that I have with this code is that, IMO, you should never retry something when an exception is thrown.  You should recover, clean up, and report the error to the user.  If you truly wish to try over, you should do that from the calling location and not inside the exception.  The second problem I have with the code is that the function is returning a result based on whether the database can be contacted, not the results of the query.  I can see the function returning false when it fails, but the error message should tell the user that the database wasn&#8217;t open, or couldn&#8217;t be connected to, or was closed; anything other than flat out lying to the user.  geesh.</p>
]]></content:encoded>
			<wfw:commentRss>http://barbecueguy.com/2006/05/10/i-love-infinite-recursion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PaulaBeans</title>
		<link>http://barbecueguy.com/2005/09/21/paulabeans/</link>
		<comments>http://barbecueguy.com/2005/09/21/paulabeans/#comments</comments>
		<pubDate>Wed, 21 Sep 2005 11:05:00 +0000</pubDate>
		<dc:creator>John Kraft</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://barbecueguy.com/?p=212</guid>
		<description><![CDATA[Non-programmers can skip this post&#8230; I found this one at The Daily WTF and, I about spit my Mt. Dew on my monitor when I read it. The Brillian PaulaBean]]></description>
			<content:encoded><![CDATA[<p>Non-programmers can skip this post&#8230;</p>
<p>I found this one at <a href='www.thedailywtf.com'>The Daily WTF</a> and, I about spit my Mt. Dew on my monitor when I read it.</p>
<p><a href='http://thedailywtf.com/forums/40043/ShowPost.aspx'>The Brillian PaulaBean</a></p>
]]></content:encoded>
			<wfw:commentRss>http://barbecueguy.com/2005/09/21/paulabeans/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

