Coding styles reference card

No explanation. Just the stuff that matters.

Layout

Indenting

4 spaces, no tabs

Maximum line length

not fixed (although above 100 is considered long)

Naming

Names are always written in CamelCase style. Not in underscore_style. The only exceptions are defines (include guards / macros).

Local variables

Variables start lower case, even if they start with an acronym.

double someVariable
Station umtsStation

Methods

Methods start lower case. They describe an action. Therefore, they should contain a verb. NVI is prefixed with do, event-based interface with on

void sendData()
void doSendData()
void onConnectionEstablished()

Classes

Classes start with an upper case letter and are written in CamelCase

class PositionProvider
class UMTSTransmitter
class WiMAXReceiver

Interfaces

Interfaces start with an I

class IComponent

Class members

End with an underscore

int bar_

Namespaces

Namespace are written all in lowercase letters

namespace wns
using namespace wns::simulator

Template Parameters

Template parameters are written in upper case letters

template <typename KEY, typename VALUE>

Macros

Marcos are written in upper case letters. Underscores should be used for better readability.

#define WNS_ADD(x, y) (x)+(y)

Include Guards

Include guards, like Macros, are written in upper case letters with underscores to enhance readability

MODULE_DIR_SUBDIR_SUBSUBDIR_FILE
#ifndef TCP_CONGESTION_TAHOE_HPP

openWNS: CodingStylesShort (last edited 2008-08-21 10:50:47 by localhost)