- General Rule: With very few exceptions, prefer embedded
capitals instead of underscores for class, function and variable
- C++ and Objective-C classes, interfaces and protocols, and other
type names - these names should start with a capital letter and use
- Local variables should use interCaps, but the first word should
start with a lowercase letter, like this:
- Free function names in C++ should follow the same naming
conventions as local variables. Most functions should be named to
sound like verb phrases, like "openDoor" or
"walkAroundTheBlock". (getters, setters, predicates?)
- C++ data members should be named like local variables, but with a
prefix of m_.
- C++ member functions should follow the same naming convention as
- Objective-C methods should follow the usual Cocoa naming style -
they should read like a phrase or sentence and each piece of the
selector should start with a lowercase letter and use intercaps.
- Objective-C instance variables should be named like local
variables but starting with an underscore.
- Pointer and reference types - pointer types should be written with
a space between the type name and the * (so the * is adjacent to the
following identifier if any). For reference types, the & goes next to
the type name.
- Enum members should user InterCaps with an initial capital letter.
- #defined constants should use all uppercase names with words
separated by underscores.
- Macros that expand to function calls or other non-constant
computation: these should be named like functions, and should
have parentheses at the end, even if they take no arguments (with
the exception of some special macros like ASSERT):
#define WBStopButtonTitle() NSLocalizedString(@"Stop", @"Go/Stop button title when busy")
#define WB_STOP_BUTTON_TITLE NSLocalizedString(@"Stop", @"Go/Stop button title when busy")
#define WBStopButtontitle NSLocalizedString(@"Stop", @"Go/Stop button title when busy")
- Acronyms in names: If an identifier includes an acronym, make the
acronym all-uppercase or all-lowercase, depending on whether a
word in that position would be capitalized or not.