<?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>Lichtman Consulting &#187; Lichtman Consulting &#8211; Coding Practices at Large Companies</title>
	<atom:link href="http://lichtman.ca/tag/object-oriented-programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://lichtman.ca</link>
	<description>Consider. Then Build It.</description>
	<lastBuildDate>Mon, 21 May 2012 09:04:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Coding Practices at Large Companies</title>
		<link>http://lichtman.ca/coding-practices-at-large-companies/</link>
		<comments>http://lichtman.ca/coding-practices-at-large-companies/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 17:43:30 +0000</pubDate>
		<dc:creator>Jeremy Lichtman</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Error message]]></category>
		<category><![CDATA[Goto?!]]></category>
		<category><![CDATA[Object-oriented programming]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://lichtman.ca/?p=333</guid>
		<description><![CDATA[I just had an interesting email exchange with one of my newer staff, a friend from university who worked for [insert name of company] for a number of years. Aforementioned anonymized company being a Fortune 500 company that is in &#8230; <a href="http://lichtman.ca/coding-practices-at-large-companies/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I just had an interesting email exchange with one of my newer staff, a friend from university who worked for<strong> [insert name of company]</strong> for a number of years. Aforementioned anonymized company being a Fortune 500 company that is in the IT industry. I&#8217;ve got stuff with their logo on it in my office.</p>
<p>The conversation began when he asked if he could use a goto statement (in PHP code!) for error handling.</p>
<p>Bearing in mind that this is somebody who is extremely familiar with both Object Oriented and good coding practises, I realized that there must be an interesting story underlying this.</p>
<p>His response to my query for more info is informative:</p>
<blockquote><p><em>Tease all you want &#8212; I&#8217;ll lean on the weight of nine years of experience at <strong>[big company name]</strong>, where (gasp) gotos were ubiquitous (almost exclusively in error handling code, but still).</em></p></blockquote>
<p>To clarify further: I actually wasn&#8217;t aware that PHP had a goto statement (see: <a href="http://php.net/goto">php.net/goto</a> &#8211; they have the nice xkcd cartoon in the comments). I&#8217;ve been coding in PHP for a <em>long</em> time.</p>
<p>There&#8217;s two methods that I usually use to handle errors in PHP code, in case you&#8217;re wondering:</p>
<p>1. Make sure that code that can crash is encapsulated in a nice neat function. Check return values of function calls inside the function. If necessary, stick an &#8220;@&#8221; before function calls that tend to crash in a messy manner. Then return useful info about the final state from the function itself, and check things out higher up in the stack.</p>
<p>2. Stick try/catch code around code that can crash. If necessary, subclass error classes and put in nice handlers for them.</p>
<p>In both cases, make sure that the error level for reporting is appropriate, and that we don&#8217;t output actual error messages back to the end user. Where useful, put in logging, and possibly put in code to email error reports back to admin.</p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/d6590b62-b2d5-4c79-bdb9-dc4d22faa2ff/"><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://img.zemanta.com/reblog_e.png?x-id=d6590b62-b2d5-4c79-bdb9-dc4d22faa2ff" alt="Reblog this post [with Zemanta]" /></a><span class="zem-script more-related pretty-attribution"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
]]></content:encoded>
			<wfw:commentRss>http://lichtman.ca/coding-practices-at-large-companies/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

