View Single Post
Old 07-16-2008, 09:42 PM   #1 (permalink)
Ross
The Contributor
 
Ross's Avatar
 
Join Date: Jan 2008
Location: England, UK
Posts: 83
Thanks: 3
Ross is on a distinguished road
Default Coding Standards

We need to make a decision on this before any code is written - and we all want to get started.

Below is my natural way of coding - there will almost certainly be parts you disagree on and will want to change. Post what you would do differently. We will work on the code type that is most popular - simply so most of us aren't working differently than the way we would normally - unless it could be more efficient to use a different format (conditionals etc.).

PHP Code:
<?php

     
/**
      * Multi line comment/docblock
      * 5 spaces / tab
      */
     
     /**
      * @class MyClass
      * @final
      */
     
final class MyClass{
          private 
$config;
          
          
/**
           * Constructor
           * @param array Argument array
           */
          
public function __construct($args){
               if(
count($args) < 10 && !is_object($args)){
                    die(
'lolage');
               }
               
               (
is_array($args)) ? echo('foo') : echo('bar');
          }
     }

?>
(May expand on tomorrow, this was a quick one).

As for tabs/spaces any decent editor will convert tabs to spaces for you. I've recently started using NetBeans for Java, and then found a PHP plugin to use with it. This supports tabs to n spaces. Tabs display differently so I propose we use spaces as standard for indetation.
Ross is offline  
Reply With Quote
The Following User Says Thank You to Ross For This Useful Post:
codefreek (07-19-2008)