Preview

Coding Conventions

Good Essays
Open Document
Open Document
377 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Coding Conventions
Coding Conventions

Table of contents
1.

Coding Style
1.1.
Global Styles
1.2.
PHP and Javascript Styles
1.3.
CSS Styles

Coding Style We stick to Zend coding style conventions: http://framework.zend.com/manual/1.12/en/coding­standard.coding­style.html Here are some important aspects of coding style that are worth mentioning for clearness sake: Global Styles
● Indentation
○ The unit of indentation is four spaces.
○ Use of tabs should be avoided because there still is not a standard for the placement of tabstops.
○ The use of spaces can produce a larger file size, but the size is not significant over local networks, and the difference is eliminated by minification.
● Line Length
○ Avoid lines longer than 80 characters.
○ When a statement will not fit on a single line, it may be necessary to break it.
○ Place the break after an operator, ideally after a comma. A break after an operator decreases the likelihood that a copy­paste error will be masked by semicolon insertion.
○ The next line should be indented 8 spaces.

PHP and Javascript Styles
● PHP tags
○ Short PHP tags ( <;? ?>;, <;?= ?>;, <;% %>; ) are never to be used.
PHP Code must always be enclosed by: <?php
?>





○ For files containing only PHP code, the closing tag must always be omitted.

Variable and Method Names
○ Names should be formed only from the 26 upper and lower case letters (A .. Z, a .. z), the 10 digits (0 .. 9), and _ (underbar).
○ Avoid use of international characters because they may not read well or be understood everywhere.
○ Member variables and methods should use camelCase formatting.
■ public function fooBar();
○ Non member variables and functions should use underscore_case formatting and be all lowercase.
■ public function foo_bar();
○ Do not use \ (backslash) in names.
○ Only use _ (underbar) as the first character of a private or protected member variable or method name.
■ private function _fooBar();
■ protected

You May Also Find These Documents Helpful

Related Topics