== Indenting == * Use spaces to indent. Tabs should not appear in code files (with the exception of files that require tabs, e.g. Makefiles). We have a Subversion pre-commit script that enforces this rule for most source files, preventing commits of files that don't follow this rule. * The indent size is 4 spaces. * Code editors should be configured to expand tabs that you type to 4 spaces. === Braces === * Function definitions — open and close braces should be on lines by themselves. Do not put the open brace on the same line as the function signature. Right: {{{ #!cpp void foo() { // do stuff } }}} Wrong: {{{ #!cpp void foo() { // do stuff } }}} * Other braces, including for, while, do, switch statements and class definitions — the open brace should go on the same line as the as the control structure. Right: {{{ #!cpp for (int i = 0; i < 10; i++) { // do stuff } }}} Wrong: {{{ #!cpp for (int i = 0; i < 10; i++) { // do stuff } }}} * If/else statements — as above, but if there is an else clause, the close brace should go on the same line as the else. Also, one-line if or else clauses should not get braces. Right: {{{ #!cpp if (timeToGetCoffee) { buyCoffee(&coffee); chugIt(coffee); } else if (timeToGoHome) // comment on else case outtaHere = true; }}} Wrong: {{{ #!cpp if (timeToGetCoffee) { buyCoffee(&coffee); chugIt(coffee); // comment on else case } else if (timeToGoHome) { outtaHere = true; } if (timeToGetCoffee) { } else // comment on else case if (timeToGoHome) outtaHere = true; }}}