Space: The Final Frontier!

TAIT's Organization

T8s.Org: Tait's; TAIT's; and Taits!

 
 
 
 

Archives

Categories

Space: The Final Frontier!

Ok Maybe it is a little cheesy to use the Star Trek motto, so let’s just get this over with!

A space is one press of the space bar on the keyboard. There, was that so hard?

Logical:
if ( ( condition1 ) || ( condition2 ) ) {
[tab]action;
}
---
Illogical:
if ( ( condition1 ) || ( condition2 ) ) {
 action;
}

if ( ( condition1 ) || ( condition2 ) ) {
  action;
}

if ( ( condition1 ) || ( condition2 ) ) {
          action;
}

A space should never be used at the beginning of a line or in the place of a tab.

Logical:
$nothing            = 'something';
$today              = 'friday';
$best               = 'friend';
$some_joes[ $best ] = 'Mary';
if ( 'something' != $nothing && 'friday' == $today ) {
    $action = "Go have a party at the house of" . $some_joes[ 'friend' ];
}

Put a space next to operands, brackets and parenthesis where allowed. One Space! This is all for readability, maintainability and error avoidance.

If you read line length (70 Characters), you will know that unusual punctuation is difficult for most people to understand. Computer code has a lot of that. Spaces serve to break this up and make it more readable, the same way spaces break up the words in a book, and make them more readable.

You can also use spaces mid-line to align assignments statements nicely.

$a = $b; // This is a proper end of line comment.

Note that after a line’s semicolon (;) a space, two slashes, a space should be added and then the comment.
Trailing spaces, as well as trailing tabs (spaces and tabs at the end of the line) must be removed.