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 |
Table data provider | table_[object name].php | table_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 |
Forms (and other actions)
The property which determines what to do, should be named action
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 |
Functions are places alphabetically in files, except for getAdditionalStructure in Datarecord class' which is allowed to be first.
Variables
Variables are initialized to the same name as the class they are representing. Variables in several words are split by underscore _
SQL
Tables are named after their corresponding classes, but in plural form, such as users
Keys | Keys are named [object name]_id such as user_id |
---|---|
Foreign keys | Foreign references are named [foreign object name]_ref such as user_ref |
In other cases the object name should never be part of the field names, so not user_first_name but only first_name
Field names are lowercase and words are split by underscore _