Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. File content must be kept within 180 columns
  2. Continuation of lines should be obvious:
    Code Block
    totalSum = a + b + c +
        d + e;
    
  3. Must indent with space not tabs. Indentation = 4 spaces
  4. Line endings should be LR (Mac / Linux format)
  5. White space:
    1. - Operators should be surrounded by a space character.
    2. - Java reserved words should be followed by a white space.
    3. - Commas should be followed by a white space.
    4. - Colons should be surrounded by white space.
    5. - Semicolons in for statements should be followed by a space character.
  6. Block layout should be as illustrated below . Class, Interface and method blocks should also use this layout.
    Code Block
    while (!done) {
        doSomething();
        done = moreToDo();
    }
    
  7. If-else clauses must use the following layout:
    Code Block
    if (condition) {
        statements;
    } else {
        statements;
    }
    
  8. The try-catch block follows the if-else example above

Statements

  1. Imported classes should always be listed explicitly. No wildcards. The list of imports should be kept minimal and organized using your IDE
  2. Class and Interface declarations should be organized in the following manner:
    1. Class/Interface documentation.
    2. class or interface statement.
    3. Class (static) variables in the order public, protected, package (no access modifier), private.
    4. Instance variables in the order public, protected, package (no access modifier), private.
    5. Constructors.
    6. Methods (no specific order).
  3. Type conversions must always be done explicitly. Never rely on implicit type conversion.
  4. Variables should be initialized where they are declared and they should be declared in the smallest scope possible
  5. Class variables should never be declared public
  6. Loop variables should be initialized immediately before the loop.
  7. The conditional should be put on a separate line. This improves debuggability when there is a failure.
  8. The use of magic numbers in the code should be avoided. Numbers other than 0 and 1can be considered declared as named constants instead.

...

  1. All Python code must be PEP-8 compliant
    1. All existing code fails this test.
  2. TODO

IDE settings file

Intellij Idea

Eclipse

  • TODO

Appendix

Naming Conventions for Design patterns used in Cloudstack Java code

...

Wiki Markup
\[2\] Java Code Conventions [http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html|http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html]\\

Attachments

Attachments