Skip to content

Latest commit

 

History

History
131 lines (108 loc) · 2.07 KB

File metadata and controls

131 lines (108 loc) · 2.07 KB

Development Standard

License

  • Public projects: MIT
  • Private projects: Proprietary
  • Header on all source code files

Editor

  • Soft tabs with 4 spaces
  • Char encoding: UTF-8 without BOM
  • Line break: Unix LF
  • No spaces before a LF

Concepts

  • Namespaces/Packages: Mandatory
  • SOLID
    • Single Responsibility Principle
    • Open Closed Principle
    • Liskov Substitution Principle
    • Interface Segregation
    • Dependency Inversion Principle

Naming Conventions

  • Class: CamelCase
  • Variables: camelBack
  • Functions: camelBack
  • Constants: UPPER_CASE

Control Structures

// When using one variable on an if statement
if (op1) {
    // code
    // code
}

// When using one variable and negating it on an if statement
if (!op1) {
    // code
    // code
}
// Using more than one variable and expression in an if statement
if ((!op1) && (op2 || op3)) {
    // code
    // code
} else {
    // code
    // code
}
// One liner, do not use curly braces same applies to other control structures
if (true)
    i = 13;
else
    i = 31;
// Swith statement
switch (expression) {
    case expression:
        // code
        break;
    default:
        // code
}
// For statement
for (i = 0; i < max; i++) {
    // code
}
// Do while statement
do {
    // code
} while (expression);
// While statement
while (op1 && !(op2 && op3)) {
    //  code
}
// Ternary statement

// Can do
    y = x.isValid() ? x.getValue() : -1;

// Can't do
// Do not call actions on ternary returns
    y = x.isValid() ? x.setValue() : -1;

Comments

 // This is the right way to do a comment
 //Don't comment like this

// JavaDoc standard
/**
 * Description of the function
 * One space before and after the asterisk
 *
 * @param Number x
 *
 * @return int
 */
 function square(x) {
     return x * x;
 }

Failures

Ensure that your code fails gracefully in unexpected situations and it reports the issue on log files.