Changes between Version 4 and Version 5 of CodingStandards
- Timestamp:
- Dec 31, 1969, 4:20:58 PM (54 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
CodingStandards
v4 v5 1 1 = OpenSHA Coding Standards = 2 Anyone working on OpenSHA should strive to write efficient, well-documented, and testable code. To facilitate uniform presentation and encourage a high level of readability, several syntactic standards to which this project adheres are outlined below. Most of the recommended syntax configurations can be set within your IDE of choice.2 Anyone working on OpenSHA should strive to write efficient, well-documented, and testable code. To encourage readability and uniform presentation, several syntactic standards to which this project adheres are outlined below. Most of the recommended syntax configurations can be set within your IDE of choice. 3 3 4 4 == Syntax == … … 10 10 '''Line Wrapping''' : Indent wrapped lines with two tabs. 11 11 12 '''Code Blocks''' : Code contained within a containing block shall always be indented by a single tab from the containing block. When creating a new block of code (i.e. functions, loops, if-statements, etc...), the opening bracket "{" shall be on the same line as the start of the block and the closing bracket shall be on its own line aligned to the opening indentation of that block. This is true except for when the code block can fit entirely on a single line, in such a case it is allowable to do so however there should be sufficient space for a leading ''and'' trailing space between the code-block body and the brackets. For example: 13 14 Good 12 '''Code Blocks''' : methods, for-loops, if-statements, etc... 13 * The opening bracket "{" of any new block should be on the same line as the start of the block 14 * The closing bracket should be on its own line aligned to the opening indentation of the block. 15 * The only exception is the case of where the entire block can fit on one line, e.g.: 15 16 {{{ 16 public void foo () { 17 ... 18 } 19 public boolean bar () { return true; } 20 }}} 21 22 Bad 23 {{{ 24 public void foo () 25 { 26 ... 27 } 28 public boolean bar(){return true;} 17 if (false) return; 29 18 }}} 30 19