19 November 2007

Thinkopen Software coding standards (ver 0.1) released

Think Open has released its coding standards that all developers and consultants will be required to adhere to.

Thinkopen Software coding standards

version 0.1


Class organization

All classes are to be organized according to the following template.

class myClass
{
//public static functions

//public constructors

//publicly defined interface

// non-public methods and fields

}


Class documentation


We are using phpDocumetor, all developers are to be familiar with the basic documentation tags.

At the file level we use the Zend Framework's template with slight modifications

/**
* Short description for file
*
* Long description for file (if any)...
*
* LICENSE: Some license information
*
* @copyright 2007 Thinkopen Software
* @version m.n.o
* @since File available since Release 1.2.0
*/
At the class level we use the Zend Framework's template with slight modifications

/**
* Short description for class
*
* Long description for class (if any)...
*
* @copyright
2007 Thinkopen Software
* @version
m.n.o
* @since Class available since Release 1.2.0
* @deprecated Class deprecated in Release 2.0.0
*/

More importantly, every single public function must minimally document it's arguments and return types. This is vitally important for enforcing type safety in our php code, as well as making exposing the classes as, for example, SOAP objects way easier.
Wherever possible use type hinting.
The following tags HAVE to be implemented on any class marked as public or protected.

@param --
  1. if the type is not a basic type, use class name
  2. if the class being accepted is not in the project, provide a @see and/or and @example for class
@return --
  1. if the type is not a basic type, use class name
  2. if the class being accepted is not in the project, provide a @see and/or and @example for class


http://pear.php.net/package/PhpDocumentor/docs/1.4.0/phpDocumentor/tutorial_tags.pkg.html


Naming conventions

Since we are running PHP (weakly typed), it's recommended that we use a modified Camel Casing with a bit of Hungarian notation thrown in.
That is, variable look like the following,
$xNameOfVariable
Where x is a letter(/s) representing the type of the variable.
i - integer
f - foating point or double (if applicable)
s - string
o - representing an instance of some class.

we also use an 'axNameOfArray' to represent an array of the type indicated by x.

Examples :
$iMyNumber - integer
$aiMyNumbers - array of integers
$oSomeObject - instance of some class
$aoSomeObjects - array of objects

Coding standard generally

All code is to conform to the standards set in the Zend Framework's coding standard as the default, except where the Thinkopen internal standard differs above

http://framework.zend.com/manual/en/coding-standard.html

Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home