Changes between Initial Version and Version 1 of DolphinCodeConvention


Ignore:
Timestamp:
Aug 24, 2010, 6:36:48 AM (14 years ago)
Author:
Andrew Boon
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DolphinCodeConvention

    v1 v1  
     1= Dolphin Code Convention = 
     2 
     3When working with Dolphin code, developing extensions and modifications, the following code convention is advised to be followed.  
     4 
     5== Class Names == 
     6All 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. 
     7 
     8Example: 
     9                         
     10{{{ 
     11BxMyClassName 
     12}}} 
     13 
     14                         
     15== Variable Declarations: Names == 
     16Given 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. 
     17//Data type prefixes:// 
     18- i Integer 
     19- f Float, Double 
     20- s String 
     21- a Array 
     22- r Resource 
     23- b Boolean 
     24- is Boolean 
     25 
     26Following the first letter every word used in the Variable Name must begin with a capital letter. 
     27 
     28Example:  
     29                 
     30{{{ 
     31        $sName = "Variable Value"; 
     32                        $iCnt = 0; $iCnt++; 
     33                        $rMyFile = fopen ("myfile.txt", "r"); 
     34                        var $isWritable; 
     35}}} 
     36 
     37                         
     383. Function Declaration: Names and Formatting 
     39All 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. 
     40Example: 
     41                        function myFunction($iNumber, $sName) 
     42                        {  
     43                                //code here 
     44                        } 
     45                         
     464. Language Structures Formatting 
     47Language structures such as if ... else, for, foreach, while, etc. must be presented in the following manner: 
     48To provide better readability of the code, there should be a space between the name of the structure and the following parenthesis 
     49For the same reason, statements concluded within the brackets should be separated with a break 
     50A similar rule applies to ternary operator 
     51There is no space after the left parenthesis and before the right parenthesis 
     52Curly braces must be on new lines 
     53Example: 
     54                        foreach ($aNames as $sKey => $sVal) 
     55                        {  
     56                                //code here 
     57                        } 
     58                         
     59switch construction 
     60The 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. 
     61 
     62Example: 
     63                        switch ($iNumber) 
     64                        {  
     65                                case 1: //code here break; 
     66                                case 2: 
     67                                        //code here 
     68                                        break; 
     69                                default: 
     70                                        //code here 
     71                        } 
     72                         
     735. Writing Your Own Code 
     74When writing your own code to modify the original script, it must be thoroughly commented to be easily distinguished from the original code. 
     75 
     76Example: 
     77                        //Extension Name. Author name.// 
     78                        SomeCodeHere(); 
     79                        //[END] Extension Name// 
     80                         
     81It's highly recommended to leave most of the original script untouched when modifying the code. All the functionality of the extension must be saved in separated files instead of the original code. The files with functionality of the modified product must be combined in 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. 
     826. Database Tables 
     83Tables used in the extensions must be named with the prefix (extension name). For example, MyModName_Users, MyModName_Passwords, etc. 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.
Fork me on GitHub