= Dolphin Code Convention = When working with Dolphin code, developing extensions and modifications, the following code convention is advised to be followed. == Class Names == All Class Names must begin with the prefix, and each word with a capital letter to avoid identical names and to make more unique classes written by the given developer. '''Example:''' {{{ BxMyClassName }}} == Variable Declarations: Names == Given no strict data classification in PHP, all Variable Names must begin with a lower case letter of the first character in the name of a particular data type prefix. '''Data type prefixes:''' - i Integer - f Float, Double - s String - a Array - r Resource - b Boolean - is Boolean Following the first letter every word used in the Variable Name must begin with a capital letter. '''Example:''' {{{ $sName = "Variable Value"; $iCnt = 0; $iCnt++; $rMyFile = fopen ("myfile.txt", "r"); var $isWritable; }}} == Function Declaration: Names and Formatting == All Function Names should start with a lower case letter, and each word should begin with a capital letter. Curly braces used in the list of parameters must be given on a new line instead of following the brackets. '''Example:''' {{{ function myFunction($iNumber, $sName) { //code here } }}} == Language Structures Formatting == Language structures such as if ... else, for, foreach, while, etc. must be presented in the following manner: - To provide better readability of the code, there should be a space between the name of the structure and the following parenthesis - For the same reason, statements concluded within the brackets should be separated with a break - A similar rule applies to ternary operator - There is no space after the left parenthesis and before the right parenthesis - Curly braces must be on new lines '''Example:''' {{{ foreach ($aNames as $sKey => $sVal) { //code here } }}} '''switch''' construction - The above rules must be applied for the switch construction itself. - The inner case-statements should be indented with the tab. - The inner case code should also be distinguished with an additional tab. - The closing break must be placed on the new line and aligned with the case. '''Example:''' {{{ switch ($iNumber) { case 1: //code here break; case 2: //code here break; default: //code here } }}} == Writing Your Own Code == When writing your own code to modify the original script, it must be thoroughly commented to be easily distinguished from the original code. '''Example:''' {{{ //Extension Name. Author name.// SomeCodeHere(); //[END] Extension Name// }}} It's highly recommended to '''leave the original script untouched''' when modifying the code. All the functionality of the extension must be saved in separate files instead of the original code. The files with functionality of the modified product must be combined into a separate folder appropriately named (extension name). Each folder should follow a system of docs i.e. cataloging to keep all pictures in the folder "images", stylesheets - in "css" folder, etc. == Database Tables == Tables used in the extensions must be named with the prefix (extension name). '''Example''' {{{ MyModName_Users, MyModName_Passwords, etc. }}}