<?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>Full On Design &#187; tips variables</title>
	<atom:link href="http://www.fullondesign.co.uk/tag/tips-variables/feed" rel="self" type="application/rss+xml" />
	<link>http://www.fullondesign.co.uk</link>
	<description>Design &#38; Web Technologies</description>
	<lastBuildDate>Sun, 30 Oct 2011 21:37:16 +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>5 Tips for Coding Cleaner PHP</title>
		<link>http://www.fullondesign.co.uk/coding/php/616-5-tips-for-coding-cleaner-php.htm</link>
		<comments>http://www.fullondesign.co.uk/coding/php/616-5-tips-for-coding-cleaner-php.htm#comments</comments>
		<pubDate>Mon, 06 Apr 2009 19:20:25 +0000</pubDate>
		<dc:creator>Rogem</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[braces]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[fulgy code]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[tips variables]]></category>
		<category><![CDATA[white space]]></category>

		<guid isPermaLink="false">http://www.fullondesign.co.uk/?p=616</guid>
		<description><![CDATA[PHP is lovely, though if you ever work with other people having good code is important. Here are some tips to improve your code. Comment &#38; Document It’s really important that people understand why you are doing certain things in certain ways. Adding a quick comment above sections of code should be adequate, but documenting [...]]]></description>
			<content:encoded><![CDATA[<p>PHP is lovely, though if you ever work with other people having good code is important. Here are some tips to improve your code.</p>
<h3>Comment &amp; Document</h3>
<p>It’s really important that people understand why you are doing certain things in certain ways. Adding a quick comment above sections of code should be adequate, but documenting classes and functions (Even if it’s in a Wiki) is fantastic.</p>
<h3>Give Variables, Functions and Classes Meaningful names</h3>
<p>Nothing is worse than trying to figure out what a function called &#8220;SIDFE()&#8221; does. Give everything a name that if someone else looked at it, they could figure out what it does. The above is a real example I have come across while adjusting a clients website, if the other programmer had called it something like Scan_Incomming_Data_For_Evil() it would have been a lot more straightforward.</p>
<h3>White space</h3>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-633" title="White Space, Good VS Bad" src="http://www.fullondesign.co.uk/wp-content/uploads/2009/04/whitespace.png" alt="whitespace" width="400" height="300" /><em>As you can see, a little space here and there makes life a lot easier.</em></p>
<p>No one likes to have to search for the start of a function. Make sure you indent your code and keep it easy to read quickly.</p>
<h3>Never Delete &#8211; Comment out</h3>
<p>This one is a little hard to grasp, but imagine you just fixed a bug (say 100 lines of code to fix it) and something else has broken. It makes sense to be able to go back and see the old code without modification of the new code. Also, doing this helps people see where an old bug was (assuming you comment that the section of code is evil) for future reference.</p>
<h3>Use Braces</h3>
<p>Braces are those neat } and { things. If you don’t use them on various functions it’s a pain to figure out where a loop starts and finishes. This is especially important when programming on a large scale because no one likes debugging fugly code. Here is an example of good and bad code:</p>
<pre class="brush: php; title: ; notranslate">&lt;?php
/* Examples of annoying code */
if ( $coder === 'Silly' ) bang_head(); 

while ( $coder === 'Silly' )
    bang_head();

/* Examples of good code*/
if ( $coder !== 'Silly' ){ Drink_Beer(); }

while ( $coder !== 'Silly' ){
    Drink_Beer();
}
?&gt;</pre>
<p><span id="more-616"></span></p>
<h3>Useful Links</h3>
<p><a href="http://tech.forumone.com/archives/46-Tips-to-write-readable-PHP-code.html">PHP coding guidelines</a><br />
<a href="http://www.smashingmagazine.com/2009/03/24/10-useful-php-tips-revisited/">10 Useful PHP Tips Revisited</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fullondesign.co.uk/coding/php/616-5-tips-for-coding-cleaner-php.htm/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: basic
Database Caching 1/9 queries in 0.005 seconds using disk: basic
Object Caching 214/229 objects using disk: basic

Served from: www.fullondesign.co.uk @ 2012-02-04 09:03:02 -->
