naming_conventions
This is an old revision of the document!
Table of Contents
Naming conventions
Objects
When refering to [object name] below, object names are always lowercase and in singular form. user not Users
File names
File type | Naming | Example |
---|---|---|
Form | [object name]_[action].frm | user_edit.frm |
Data loader | load_[object name].php | load_user.php |
Data saver | save_[object name].php | save_user.php |
Data load+save | io_[object name].php | io_user.php |
HTML
Elements
Element | Form | Example |
---|---|---|
Action | [object name]-[action] | user-edit |
Button | [object name]-[activity]-button | user-edit-button |
Dialog | [object name]-[activity]-dialog | user-edit-dialog |
Form | [object name]-form | user-form |
Menu | [object name]-form | user-menu |
Table | [object name]-table | user-table |
Javascript
Functions
Functions should be dromedaryCase
PHP
Classes
Classes are CamelCase and in singular form
Functions
Functions should be dromedaryCase
Class functions should be named according to what they do:
calculate | Calculates something within the object |
---|---|
can | Check if the object is able to do something |
get | Gets some information from the object |
is | Check if the object is in a given state. |
load | Retrieves object information from somewhere |
save | Stores object information somewhere |
set | Set some information in the object |
SQL
Tables are named after their corresponding classes, but in plural form, such as users
Keys | Keys are named [object name]id such as userid |
---|---|
Foreign keys | Foreign references are named [foreign object name]ref such as userref |
In other cases the object name should never be part of the field names, so not userfirstname but only firstname
naming_conventions.1568450923.txt.gz · Last modified: 2019/09/14 08:48 by sahl