User Tools

Site Tools


naming_conventions

This is an old revision of the document!


Naming conventions

Objects

When refering to [object name] below, object names are always lowercase and in singular form. user not Users

File names

File typeNamingExample
Form[object name]_[action].frmuser_edit.frm
Data loaderload_[object name].phpload_user.php
Data saversave_[object name].phpsave_user.php
Data load+saveio_[object name].phpio_user.php

HTML

Elements

ElementFormExample
Action[object name]-[action]user-edit
Button[object name]-[activity]-buttonuser-edit-button
Dialog[object name]-[activity]-dialoguser-edit-dialog
Form[object name]-formuser-form
Menu[object name]-formuser-menu
Table[object name]-tableuser-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:

calculateCalculates something within the object
canCheck if the object is able to do something
getGets some information from the object
isCheck if the object is in a given state.
loadRetrieves object information from somewhere
saveStores object information somewhere
setSet 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

KeysKeys are named [object name]id such as userid
Foreign keysForeign 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.1568464204.txt.gz · Last modified: 2019/09/14 12:30 by sahl

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki