Naming Standards | C Plus Plus Standards
Summary
These are the standards for naming within C++ documents across SGE products.
1. United Kingdom Based English
Where spelling differs among US and UK English, UK english is to be used.
1. Example
1. Reason
Consistency has to be established and the founder is from the United Kingdom and therefore the foundational files have been named in this manner.
2. Classes, Structs, Enums and Methods begin with a Capital Alphabetical Character
All classes, structs, enums and methods must begin with a letter from A to Z nothing else. They must also begin with a capital letter.
2. Example
2. Reason
It is important to expect an external object types to conform to a certain structural naming scheme.
3. Types and Methods (Classes, Enums, Structs) are named Upper CamelCase
All classes, structs, enums, methods and types such as any exception types must be named upper CamelCase.
3. Example
3. Reason
Upper camel case keeps the line length small whilst leaving text easy to read. There are a few exceptions to this rule but they are called out explicitly.
4. Private Member properties / fields are prefixed m underscore
All member properties, meaning private variables stored by a class but not accessible by externals are prefixed with an m_
4. Example
4. Reason
It is easier to figure out the origin of a variab le with the prefix. This is especially true when looking at the code via review software or diffing software.
5. Public Variables are named UpperCamelCase
Although these should be avoided in general, if there cases for public variables in a class, name them with UpperCamelCase no underscores or anything else.
5. Example
5. Reason
A public variable may as well be a method or other such vulnerability within a given class as anything externally could access it. This means two things, firstly external objects should expect interactions with classes as UpperCamelCase and that the likelihood it changes to a method to be higher than other sections of code (as functionality increases). As this consonance of name is spread around it minimizes the amount of change to already name the variable in such a way as to imply it is public and vulnerable to change from the outside world.