Coding standard
Must follow the KISS principal. `Keep It Simple, Stupid!`
The rules set name function in controller:
1. To start 1 function in controller or model, without comment/description:
a) Must include the following terms:
- @param, @return, @todo if incomplete
- @author, separated by comma
2. Controllers:
a) When function action a operation into database: * Cases: add, new, create, insert, save,.. General, when create a new item, will set name function is: addAction()
- Cases: edit, update, insert,.. These case, will set name function is: updateAction()
- Beside, delete, move,.. will set name function is: deleteAction()
- When show a list items, should using showAction(). Not use `list`.
- The name of function has remind for users.
- Example: importFilePhrasesAction() => mean as export a file which contain data in Phrases table.
3. Models:
- All functions return a boolean must start with `is` or `has`.
- All functions from models start with `find` must return Zend_Db_Table_Rowset
- All functions from models start with `fetchRow` must return Zend_Db_Table_Row
- All functions return SQL statement must end with `Sql`. E.g. `getUsernameSql`
- `get` returns results.
- `show` displays results.
- `list` should be omitted.
4. General:
- Incorrect indentation. No tabs should be used. ONE tab = 4 spaces.
- Incorrect punctuation. There must be ONE space after [,.:;()]... (comma, full stop, semi-colons, etc). No space before.
- Variable, Class must be `noun`, function must be `verb`.
- In addition, name of function must been set lowercase a word in th first, uppercase next words. The last is Action().
5. Database:
- Please use the following convention http://www.smart-it-consulting.com/database/progress-database-design-guide/
- Please note that we do not want to use shortcut! Not everyone know how to use abbreviate.
----------------------------------
Sources:
- Please use the following coding standard: http://framework.zend.com/manual/en/coding-standard.html
- And document by Mr.Danny.
No comments:
Post a Comment