Coding Guidelines

From Glacsweb Wiki
Revision as of 21:39, 25 May 2008 by Km (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This page (originally by Al)is not intended to be a set of rules, but rather a set of guidelines to ensure that the base station code that we are working on together is legible to everyone, and reasonably consistent.

Every file should have a doxygen header so we can maintain live docs.

Indenting

In order to ensure the structure of the code is obvious, it is important that every use similar indenting. I propose the most readable style is to use 4 spaces to indent a block of code, as follows:

int main(int argc, char ** argv)
{
    int i;

    printf("Hello world\n");
    for (i = 0; i < 10; i++) {
        if (i == 5) {
            printf("i is 5\n");
        }
    }
}

Curly brackets

Opening curly brackets should always be at the end of a line, and closing curly brackets should always be at the beginning of a line. If clauses should always be contained in curly brackets, as this ensure classic bugs do not occur.