Skip to content

Naming conventions

Zalasus edited this page May 14, 2018 · 1 revision

Try to be consistent with the style used in the project when making commits. As this project 'grew naturally' initially, you may find some code that does not follow all of these rules. Please don't take this as a warrant to disregard them yourself.

File names

Header files use *.h extension, sources use *.cpp.

Use upper CamelCase for file names. Source and header file names should be descriptive of course. Ideally, they will be identical to the main class they contain. If that is not applicable, the name should relate to the contained classes in some way.

As an example: A header declaring the two classes DataReader and DataWriter might be called DataStream.h

Identifier names

See also Code style conventions.

  • Use lower camelCase for variables and functions
    • Prefix member variables with m
    • Prefix static member variables with sm
    • Prefix private member functions with _
  • Use upper CamelCase for classes, structs, enums and unions
  • Use upper CamelCase for enum members
    • If you use unscoped enums (you shouldn't), prefix them with Xyz_, where Xyz is in some way descriptive of the enum
  • Use CAPS and underscores for preprocessor macros
  • In acronyms, only capitalize the first letter (or not at all if in a camelCase context)

Clone this wiki locally