View Single Post
Old 10-16-2008, 05:20 PM   #5 (permalink)
ReSpawN
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

@ All the above, I couldn't agree more.

What they said, comment your code, use white-space to your advantage, be clear with variable names and so forth.

As opposed to:
PHP Code:
$fin
// Use
$finishedString
// or
$strFinished
// or
$vFinished 
The first I would be most likely to use, but the str and v are a bit more clear if you're writing complete, long, clear code. str stands for string, obviously, and v stands for variable. You can also work with sFinished which the s would declare it to be a string.

Also, you should form up your comments with newlines and explain what you're doing. It doesn't have to be pretty, you wouldn't need to great a peice of ASCII art of sorts, but just explain the function. Therefor the name, description, static function, an example (how it could be used in your script) and so forth.

Don't be shy of using a couple of enters while you're at it.
PHP Code:
if($this->variable){
      function(
$var1,$var2,$var3);

is a bit too tight if you ask me. I would rather use this as a template.
PHP Code:
if ($this->variable) { 
      function (
$var1$var2$var3 false);
}

// or

if( $this->variable ) {

      function( 
$var1$var2$var3 false ) {


The type of coding doesn't really matter. A way that ALWAYS works, if you get a couple of beers in, then check out the code in the early hours and THEN completlely, down to the letter, understand what it is about, you've written self-explandetory code.

One more for the road. Try to comment your code as wisely as you can.
PHP Code:
/* Name        : name
 * Values      : $var1( integer), var2( string )
 * Example     : name( $var1, $var2 );
 * Returns     : float
 * Build:      : 1.0
 */
function name$var1$var2$var3 false$var4 ) {
      
      return 
someClass::someFunction();


Good luck and I hope this helped.
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote