Skip to content

Coding conventions

vhirtham edited this page Dec 5, 2018 · 7 revisions

Naming

General naming

  • name should make the purpose of the variable/class (instance) obvious
  • if the name consists of multiple words, each new word starts with a capital letter
  • don't use underscores inside the name. Don't write something like my_varible. It should be myVariable
  • Avoid abbreviations. Only use them if it is totally clear what they mean.

Class names

  • Class names always start with a capital letter

Function names

  • Start with a capital letter (exceptions: if the class needs to match a certain template interface, for example the allocators or the spinlock which should be used with STL locks)
  • Return type should be (generally) derivable from the functions name. For example IsValid or HasNewData implies a bool as return value and GetNumTriangeles an integer type

Variabes / Instances

  • always start with a small letter
  • class member variables get the prefix "m" (mMyMemberVariable)

Template parameters

  • Start with an underscore
  • The name starts with a small letter
  • Follow the general naming conventions
  • example: _templateParameter

Typedefs / using

  • If you use using or typedef the naming of the alias type follows the Class naming conventions
Clone this wiki locally