<?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; coding-standards</title>
	<atom:link href="http://www.procata.com/blog/archives/tag/coding-standards/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>PHP Coding Standards</title>
		<link>http://www.procata.com/blog/archives/2004/09/24/php-coding-standards/</link>
		<comments>http://www.procata.com/blog/archives/2004/09/24/php-coding-standards/#comments</comments>
		<pubDate>Fri, 24 Sep 2004 19:03:07 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software Design]]></category>
		<category><![CDATA[coding-standards]]></category>
		<category><![CDATA[pear]]></category>
		<category><![CDATA[refactoring]]></category>

		<guid isPermaLink="false">http://www.procata.com/blog/archives/2004/09/24/php-coding-standards/</guid>
		<description><![CDATA[I have to disagree with Paul Jones on coding standards:

The thing about defining a coding style standard is that there is no objective means by which to judge one style as â€œbetterâ€ or â€œmore-rightâ€ than another.

I can think of several objective criteria for judging coding standards practices off the top of my head:

Does the practice [...]]]></description>
			<content:encoded><![CDATA[<p>I have to disagree with Paul Jones <a href="http://paul-m-jones.com/blog/index.php?p=34">on coding standards</a>:</p>
<blockquote><p>
The thing about defining a coding style standard is that there is no objective means by which to judge one style as â€œbetterâ€ or â€œmore-rightâ€ than another.
</p></blockquote>
<p>I can think of several objective criteria for judging coding standards practices off the top of my head:</p>
<ul>
<li>Does the practice allow more code to be fit on the screen/page at one time (braces on the same line)</li>
<li>Does the code use white space to emphasize when things should be separate (spaces after commas)</li>
<li>Can the code written to the standard be viewed in multiple media and multiple editors (spaces not tabs, limited line lengths)</li>
<li>Does the practice conserve keystrokes (tabs not spaces, no spaces after commas <img src='http://www.procata.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> )</li>
<li>Does the practice facilitate copy and pasting (single statement of code per line)</li>
<li>Does the practice require extra work to maintain the code (java docs and formatted comment headers are harder to edit beceause of the prefix, aligning equals signs, etc)</li>
</ul>
<p>Obviously some practices can cause conflicts between criteria.  In this case, readability should triumph over key strokes.  Practices that require require editing unrelated lines during maintenance should be avoided.</p>
<p>One thing that I have found about refactoring is that no code smell is too small to fix.  Having your code in refactored normal form and the process of getting it there by performing small, seemingly unimportant refactorings can reveal the major refactorings that are really worth it.  Sometimes the major changes that need to be made are obscured by minor code smells.</p>
<p>Coding styles perform a similar function. Having your code in a &#8220;normalized&#8221; form frees the mind to consider other aspects of the code.  Poorly or inconsistently styled code can obscure refactorings.  With a good coding standard, the benefits outweigh having to re-train yourself out of a few habits.  I agree with Paul&#8217;s conclusion here.</p>
<p>Fortunately, the <a href="http://pear.sourceforge.net/en/standards.php">PEAR standards</a> has made the right decisions regarding these criteria with a couple of minor exceptions and many omissions.</p>
<p>The exceptions as I see them:</p>
<ul>
<li><a href="http://pear.sourceforge.net/en/standards.funcdef.php">aligning equal signs</a> should be discouraged.</li>
<li>The braces policy for <a href="http://pear.sourceforge.net/en/standards.funcdef.php">functions</a> should match that of <a href="http://pear.sourceforge.net/en/standards.control.php">control structures</a></li>
<li><a href="http://pear.sourceforge.net/en/standards.naming.php">embedding inheritance heirarchy into the class name</a> is bad</li>
</ul>
<p><strong>UPDATE:</strong> Looks I am not the only one who thinks <a href="http://blog.colorstudy.com/ianb/weblog/2004/09/22.html#P158">bad style is a bad smell</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.procata.com/blog/archives/2004/09/24/php-coding-standards/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>

