Coding Standards
We have established a set of keyed coding standards for developers, these take the form of PSnnnn where "PS" stands for "Platform Standard", the first two digits are the area and the second two are the rule within that area. See the Coding Guidelines topic for a prose description of most of these.
General (PS00xx)
- PS0001: Prefer DRY ("don't repeat yourself")
- PS0002: Provide convenience APIs for common cases
Naming (PS01xx)
- PS0101: Method spec parameter must be last and named "spec"
- PS0102: Spec types names should end in "Spec"
- PS0103: Spec types must mixin in Spec
- PS0104: Result types names should end in "Result"
- PS0105: Result types must mixin in Result
- PS0106: Use CamelCase (initial capital) for type names
- PS0107: Use camelCase (initial lower case) for field names
- PS0108: Treat acronyms as words: "Ts", not "TS" for "timeseries"
- PS0109: Avoid "get/is/has" prefixes for accessors
- PS0110: Use "as" prefix for coercion
- PS0111: Use "to/from" prefixes for conversion
- PS0112: Use "is" prefix for predicate methods, no prefix for boolean data fields
- PS0113: Use "for" prefix for lookup methods
- PS0114: Use "safe" prefix that depend on state and may compute if missing
- PS0115: Use singular names for single values
- PS0116: Use plural names for collection values
- PS0117: Use "set" prefix for mutation - update
- PS0118: Use "remove" prefix for mutation - delete
Type Files (PS02xx)
- PS0201: Use 2-space indentation
- PS0202: Do not use tabs inside documentation comments
- PS0203: Wrap lines at 120 characters
- PS0204: One blank line between public field declarations
- PS0205: Use Markdown in comments (not HTML nor JavaDoc)
- PS0206: Public types and field declarations should have a documentation comment
- PS0207: Use "/**" for documentation comments
- PS0208: Line up asterisks in comments
- PS0209: Paragraphs are separated by blank lines
- PS0210:
@paramdescription on separate line indented 3 spaces - PS0211:
@paramand@returndescriptions should be 1 or more sentence fragments - PS0212: No spaces between field name and colon and 1 or more spaces after colon
- PS0213: Mark required parameters and return values with
! - PS0214: Use
Type#fieldfor references in@linkand@see - PS0215: Put
@seedeclarations last in comment in a single block - PS0216: Use
@linkinline in descriptions - PS0217: Provide finalVersion with
@deprecated - PS0218: Provide details with
@deprecated - PS0219: Do not declare unnecessary method overrides
- PS0220: Avoid redundant prefixes in field names
Coding Style (PS03xx)
- PS0301: Use lambdas to avoid loop blocks
- PS0302: When defining methods, place lambda parameter last