Coding Standards
general
Generally speaking, we will try to stick on the KISS principle.
We can use Zend Framework coding standards apart for:
- control structures
- function "start" in classes
control structures
Always "break line" before curly brakets
//if example
if($mytest='bob')
{
//code here
}
//foreach example
foreach ($test as $key=>$value)
{
//code here
}
//switch example
switch ($test)
{
case 1:
break;
case 2:
break;
//etc.
}
functions
Always "break line" before curly brakets
// --------------------------------------------------------------------
/**
* Enter description here...
*
* @param array $myar
* @param string $myvar2
*/
function myfunction($myar, $myvar2)
{
//code here
}
comments
simple comments
It's better to begin a comment with a simple space, like
// blabla
instead of
//blabla
because it's more readable.
phpDocumentor
Comments should be written in phpDocumentor style (Zend studio does it by default).
Usefull resources:
Extra
using "code templates"
What Dan suggests is to use a kinda code templates (as they are called in Zend studio => here we go with some for CI ). The usage of this tempplates has the benefit of:
- help the coder to accomplish the coding standards
- speed up typing
Helpers
I think that it would be handy to organize helpers in classes, in order to ease their customisation. Once they are organized in classes it would be easy for the end-user to extend the class and override the official released helpers functions without having to hack the original code! Example coming soon...
