-
Notifications
You must be signed in to change notification settings - Fork 0
Coding Conventions
Mario Stanke edited this page May 7, 2019
·
4 revisions
3. Placement of braces (as in the linux kernel coding style):
if (x > 5) {
decrease(x);
...
}
Do not unnecessarily use braces where a single statement will do. Place braces like this:
if (condition)
action();
if (condition)
do_this();
else
do_that();
but in an if-else-statement treat both parts the same:
if (condition) {
do_this();
do_that();
} else {
otherwise();
}
In a function definition:
EdgeSet validActions(State s){
EdgeSet actions;
...
return actions;
}
Place the * of pointers before the variable name rather than after the type:
char nucleotide, *sequence;
double *x;
Place a space after enumerating commas:
if (parse(x, y, z))
do(a)
Do not place any trailing white spaces at the very end of a line.
Use one space around (on each side of) most binary and ternary operators, such as any of these:
= + - < > * / % | & ^ <= >= == != ? :
use a space after the keywords if, switch, case, for, do, while, e.g.
for (int i = 0; i < n; i++) {
do(i);
}