3. Indendation

Among developers, indentation of code is one of the most heated points of discussion. There are several 'good' ways to use whitespace when writing source code and all are 'right' in some respect. The only bad indentation is no indentation at all.

To make code easy to read, a common way of using whitespaces is needed across a team of developers:

Only a few lines of a file are allowed to be not indented. These are the initial comment lines of the file header and the opening and closing braces around the code.

Do

/**
 ... initial header
 */

{   // opening brace at start of code

    // my first variable, 4 spaces indentation

    integer first_int_variable = 42;

    if (first_int_variable > 42)
    {
	// 8 spaces (== 1 tab character) indentation
	doSomething ();
    }
    else
    {
	somethingDifferent();
    }

    // final return

    return first_int_variable;

}   // closing brace

Don't

	/* ... initial header  */

{	// opening brace at start of code

// my first variable, bad indentation

integer first_int_variable=42;

if(first_int_variable>42) doSomething ();
else somethingDifferent();
return first_int_variable;}