Skip to content
FGrosse edited this page Feb 26, 2013 · 9 revisions

This wiki page describes the (code) style guide for the ARA-SIM project. The Google Style Guide for C++ might be a good starting point ...

Indent

We use 4 Spaces per level of indentation.

Naming Conventions

Type Rules for Naming Examles
Classes
Interfaces
Class names should always be nouns in mixed case with the first letter of each word capitalized. Try to keep the names as descriptive as possible. Pure virtual interface classes shall not include the word interface or be prepended with an I. Abstract classes on the other hand can contain the word Abstract at the beginning if it seems reasonable. RoutingTable
AbstratARAClient
Methods Method names should always start with a verb and have the rest of the name in mixed case with the first letter in lower case. run
updatePheromoneValues
Variables All non static variables shall begin with a lower case letter and have the rest of the name in mixed case. Try to keep the names as meaningful as possible. All variable names should be enough to understand what this variable stands for. Long variable names are absolutely allowed to reach this goal. One-character variable names should be avoided except for temporary "throwaway" variables. Common names for temporary variables are i, j, k, m, and n timeInSeconds
destination
evaporationFactor
i
Constants The names of (class) constants should be all uppercase with words separated by underscores ("_"). MAGIC_NUMBER = 1
USE_SPECIAL_MODE=false

Statements

Simple Statements

Each line should contain at most one statement.

Conditional Statements

The if-else class of statements should have the following form:

if (condition) {
    statements;
}

if (condition) {
    statements;
} else {
    statements;
}

if (condition) {
    statements;
} else if (condition) {
    statements;
} else {
    statements;
}

Note: if statements always use braces, {}. Do not use the following error-prone form:

if (condition) //AVOID! THIS OMITS THE BRACES {}!
    statement;

Pointers

Avoid the usage of NULL. Bjarne Stroustroup explained it briefly over here. The new C++ standard introduces a typesafe variant of NULL called nullptr. Use nullptr over NULL.

Exceptions

Clone this wiki locally