Coding Standards
From ESEEWiki
Contents |
[edit]
If statements:
- Put parentheses around every condition
- Brackets only required for multiple lines
- Comment under the if statement
- Brackets get their own lines
- Else if on same line
if ((condition1) && (condition2))
// comment explaining the if condition
{
...
}
else if (condition1)
// comment explaining the if condition
{
...
}
[edit]
Functions:
- Function name in lowercase or camelCase
- Comments under function header as shown
function functionName($arg1, $arg2)
// takes: string, string
// returns: string
// description: this function does...
{
}
[edit]
Variables:
- Note in PHP variable types don't exist
- Variable names in lowercase or camelCase
int myAwesomeVar; string name;
[edit]
Comments:
- Above line of code if longer or a sentence
- To the right of line if a clause or short
// what the below code does something.function($arg1, $arg2); OR? something.function($arg1, $arg2); // elizabeth's way
[edit]
Classes:
- Keep member variables private, and use public getter functions
- Class names start with capital letters
- Each class has a private member variable, $db, to access the database
class Section
{
private $sectionId;
$this->db->runQuery(...);
}
