Coding Standards

We have them for a reason. Follow them.

The Unbreakables

If you break either of these rules, you will be punched in the face.

Indentation

This rule must not be broken, all indents in programming code will be hard tabs (read: not spaces). Soft tabs (spaces) may be acceptable in LaTeX code only where using a hard tab seems inappropriate.

Spaces around operators

ALWAYS put spaces around operators, i.e:

a = b
  or
c < b + a

You will be in big trouble if something like x<y is anywhere in the code.

Document your code

We will use Doxygen to create documentation of our code so make sure you comment your code using JavaDoc? style comment blocks.

Links:

The Rest

Comments

There will be no inline comments so comments about a specific line will be on the preceding line.

//This code adds
c = a + b;

Comments for a function will be before the function has been declared. The following example shows Doxygen compliant comments:

/**
 * This function does this.
 * @param input1 is ...
 * @return something...
 */
function name(input1)
{

    statements;
    ...

Braces

Braces will always be on the next line and must always be used, even for if/while/for statements with only one statement following. It may be inconvenient to type, but it makes inserting code much easier and makes the code more readable overall.

if(expression)
{
    statement;
}

Pointers

When declaring a pointer use:

type *var
not type * var or type* var

For casting, use:

(type*) var

Casting

When casting a variable use:

(type) var
not (type)var

Functions

Please use:

funcName(args)
not
funcName (args)