Skip to content

Coding conventions

vhirtham edited this page Jul 10, 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 which don't occur in the list at the end of this site. 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
  • 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

List of Abbreviations

Here is a list of commonly used abbreviations used in the code. Try to stick to this scheme. Only use abbreviation which are not listed here, if their meaning is obvious. If a common abbreviation is missing, feel free to add it.

  • num: meaning: "number of" - example: numAllocations
  • ptr: meaning: "pointer" - example: currentDataPtr
Clone this wiki locally