Difference between revisions of "Coding Standards"

From FusionPBX
Jump to: navigation, search
(Coding standards)
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Coding standards==
 
 
* '''General'''
 
* '''General'''
** class names
+
** class, method, function and variable names
*** intuitive
 
*** lower case
 
*** words separated with an underscore
 
** method names
 
*** intuitive
 
*** lower case
 
*** words separated with an underscore
 
** function names
 
*** intuitive
 
*** lower case
 
*** words separated with an underscore
 
** variable names
 
 
*** intuitive
 
*** intuitive
 
*** lower case
 
*** lower case
 
*** words separated with an underscore
 
*** words separated with an underscore
 +
*** do not abbreviate the words unless it makes the name excessively long.
 +
*** indentation use tabs instead of spaces
 +
*** recommended to code with editor showing invisible characters to prevent trailing spaces and tabs.
  
 
'''Applications'''
 
'''Applications'''
Line 38: Line 28:
 
* app_defaults.php
 
* app_defaults.php
 
** is run during the install and when upgrade schema is called
 
** is run during the install and when upgrade schema is called
* app_languages.php
+
* [[app_languages.php]]
 
** defines a php array of the words, phrases and sentences used in the project
 
** defines a php array of the words, phrases and sentences used in the project
  
Line 60: Line 50:
 
* fields
 
* fields
 
** domain_uuid
 
** domain_uuid
** primary key name is defined by  for the table use the name of the table without
+
** primary key name is the non plural name of table without the v_ prefix.
 
*** How to create the primary key name
 
*** How to create the primary key name
 
**** If the table name is v_users take remove the 'v_', make it non-plural and add '_uuid' to the end of the field name. In this example the primary key would be user_uuid
 
**** If the table name is v_users take remove the 'v_', make it non-plural and add '_uuid' to the end of the field name. In this example the primary key would be user_uuid
 +
 +
'''Code Documentation'''
 +
* http://www.phpdoc.org/

Latest revision as of 17:29, 29 August 2013

  • General
    • class, method, function and variable names
      • intuitive
      • lower case
      • words separated with an underscore
      • do not abbreviate the words unless it makes the name excessively long.
      • indentation use tabs instead of spaces
      • recommended to code with editor showing invisible characters to prevent trailing spaces and tabs.

Applications

  • apps are stored in fusionpbx/app directory
  • root.php
    • ensures the document_root server variable is set and then sets the include path from the root of the website
  • app_config.php
    • application
      • app_name
      • app_uuid
      • app_category
      • app_subcategory
      • app_description
    • menu
      • defines location in the menu
    • permissions
      • defines the permissions the application uses
      • and the default groups assigned to those permissions
    • data schema
      • define the structure of the field names, and types
  • app_defaults.php
    • is run during the install and when upgrade schema is called
  • app_languages.php
    • defines a php array of the words, phrases and sentences used in the project
  • Files
    • names
      • written in lower case
      • words are seperated by an underscore
      • use full words when possible
      • do not prefix with 'v_' files that are currently prefix in this way will be renamed to remove the 'v_'
    • program showing invisible spaces
      • to eliminate tabs and spaces at the end of a line
    • line feed only
      • no carriage return and line feed

Database

  • tables
    • prefixed with v_ this may be configurable in the future
    • tables names are plural unless the name is used is an Acronym
    • use full words not abbreviations
    • uuids used for relational id instead of auto increment identifiers
  • fields
    • domain_uuid
    • primary key name is the non plural name of table without the v_ prefix.
      • How to create the primary key name
        • If the table name is v_users take remove the 'v_', make it non-plural and add '_uuid' to the end of the field name. In this example the primary key would be user_uuid

Code Documentation