Skip to content

Latest commit

 

History

History
66 lines (59 loc) · 990 Bytes

codingStyle.md

File metadata and controls

66 lines (59 loc) · 990 Bytes

Indentation

4 spaces

Parentheses

Put them directly after the statement see:

switch (suffix) {
case A:
    statement;
case B:
    statement;
default:
    statement;
}

Functions

Only the parentheses of functions are different

int foo(int x, char y)
{
    body of the function...
}

If-Statement

Use parentheses if there are multiple statements.

if (condition) {
    statements;
}

Don't use them if you only have one statement.

if (condition)
    statement;

except you don't have only one statement in each if-body.

if (condition) {
    statement;
    statement;
    statement;
    ...
} else if (condition) { <- use them here
    statement;
} else {
    statement;
    statement;
}

Spaces

use spaces after these words:

  • if
  • switch
  • case
  • for
  • do
  • while

But don't use spaces after function names. Don't add spaces around statements inside parentheses

Naming

local variables can be short but global variables must be clear