Menu

Code_Conventions

Bohdan Stelmakh benblan

[Project Guidelines and Rules]

Default Code Convention

Freesynd uses the Google C++ Style Guide for its coding style. But there are rules that are specific to this project.
We also use the recommandations based on this site : https://github.com/cpp-best-practices/cppbestpractices by Jason Turner

Project Specific rules

Naming

Variable Names - Google

  • Variables names are in lowerCamelCase (ex: agentCount)
  • Class data members names are in lowerCamelCase and end with a trailing underscore. (ex: agentCount_)
  • Don't use type prefix in variable names (ex: i_number)

Function Names - Google

  • Function names are in lowerCamelCase
  • Function names should start with a verb
  • Getter must have the same name as the member variable it exposes.
    • If function is a getter to a computed value that is not a member variable, then it should start with "get". (ex: getDiscreteDirection())
  • Setter should be prefixed with "set" and the name of the member variable. (ex: setAgentCount(int count))
  • When defining virtual functions for subclasses to implement :
    • if function is used to delegate the work to a subclass and it is called systematically, the function should start with "do". (ex: doInitialize())
    • if function is called systematically but it is optional to implement, the function should start with "handle". (ex: handleShow())
    • if function is called using event notification, then the function should start with "on" followed by the event name. (ex: onMissionEndedEvent())

Code Formating

Indentation - Google

Indention with 4 spaces, no tabs.

Curly bracket for blocks - Google

No difference with Google standard, just to be clear!

ReturnType ClassName::functionName(Type par_name1, Type par_name2) {
  DoSomething();
  ...
}

Related

Wiki: Project Guidelines and Rules

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.