1. Variable Names
Variable names are all lowercase, with underscores between words. Class member variables have trailing underscores.
1. Constant Use a k
followed by mixed case: kDaysInAWeek
.
All compile-time constants, whether they are declared locally, globally, or as part of a class, follow a slightly different naming convention from other variables. Use a k
followed by words with uppercase first letters:
const int kDaysInAWeek = 7;
1.2 Global Variables
There are no special requirements for global variables, which should be rare in any case, but if you use one, consider prefixing it with g_
or some other marker to easily distinguish it from local variables.
1.3 Function Names
Regular functions have mixed case;
Functions should start with a capital letter and have a capital letter for each new word. No underscores.
If your function crashes upon an error, you should append OrDie to the function name. This only applies to functions which could be used by production code and to errors that are reasonably likely to occur during normal operation.
AddTableEntry() DeleteUrl() OpenFileOrDie()
2. Prefer inline functions, enums, and const
variables to macros.