Changes between Version 3 and Version 4 of DolphinCodeConvention
- Timestamp:
- Aug 24, 2010, 6:47:04 AM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DolphinCodeConvention
v3 v4 38 38 39 39 40 3. Function Declaration: Names and Formatting 40 == Function Declaration: Names and Formatting == 41 41 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. 42 Example: 43 function myFunction($iNumber, $sName) 42 43 '''Example:''' 44 45 46 {{{ 47 function myFunction($iNumber, $sName) 44 48 { 45 49 //code here 46 50 } 51 }}} 52 47 53 48 4. Language Structures Formatting 54 == Language Structures Formatting == 49 55 Language structures such as if ... else, for, foreach, while, etc. must be presented in the following manner: 50 To provide better readability of the code, there should be a space between the name of the structure and the following parenthesis 51 For the same reason, statements concluded within the brackets should be separated with a break 52 A similar rule applies to ternary operator 53 There is no space after the left parenthesis and before the right parenthesis 54 Curly braces must be on new lines 55 Example: 56 57 - To provide better readability of the code, there should be a space between the name of the structure and the following parenthesis 58 - For the same reason, statements concluded within the brackets should be separated with a break 59 - A similar rule applies to ternary operator 60 - There is no space after the left parenthesis and before the right parenthesis 61 - Curly braces must be on new lines 62 63 '''Example:''' 64 65 66 {{{ 56 67 foreach ($aNames as $sKey => $sVal) 57 68 { 58 69 //code here 59 70 } 71 }}} 72 60 73 61 switch construction 62 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. 74 '''switch''' construction 63 75 64 Example: 65 switch ($iNumber) 76 - The above rules must be applied for the switch construction itself. 77 - The inner case-statements should be indented with the tab. 78 - The inner case code should also be distinguished with an additional tab. 79 - The closing break must be placed on the new line and aligned with the case. 80 81 '''Example:''' 82 83 84 {{{ 85 switch ($iNumber) 66 86 { 67 87 case 1: //code here break; … … 72 92 //code here 73 93 } 94 }}} 95 74 96 75 5. Writing Your Own Code 97 == Writing Your Own Code == 76 98 When writing your own code to modify the original script, it must be thoroughly commented to be easily distinguished from the original code. 77 99 78 Example: 100 '''Example:''' 101 102 103 {{{ 79 104 //Extension Name. Author name.// 80 105 SomeCodeHere(); 81 106 //[END] Extension Name// 107 }}} 108 82 109 83 It'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. 84 6. Database Tables 85 Tables used in the extensions must be named with the prefix (extension name). For example, MyModName_Users, MyModName_Passwords, etc. 110 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. 111 112 == Database Tables == 113 Tables used in the extensions must be named with the prefix (extension name). 114 115 '''Example''' 116 117 MyModName_Users, MyModName_Passwords, etc.