I'm little bit confused about constants naming.
kName
NameKey
NAME_KEY
Definitely usage of these fashions?
I'm little bit confused about constants naming.
kName
NameKey
NAME_KEY
Definitely usage of these fashions?
According to Coding Guidelines for Cocoa, constances created with const shoul look like this:
The format for const constants is exemplified by the following declaration:
const float NSLightGray;
To see guidelines click here
I suggest to pick your own project or company prefix (like NS or AV above) and stick with it. So, if your prefix is AB:
ABMegaTopKey
for const
variablesAB_MEGA_TOP_FLAG
for #definesApple uses different style depending, I guess, on who wrote the project and when was it written.
kName
is used for string or variable constants.
NAME_KEY
is used for #define constants.
kName is Apple style, while NAME_KEY is alot more widespread among other languages. Doing a lil more research: k is hungarian notation
I always use the third style coming from a mainly C background, although I will usually put a prefix on them for frameworks e.g.
NSString* const JP_NAME_KEY = @"name";
there are a few visible 'cultures' in naming constants across the libraries.
I typically declare constants quite literally, using upper Camel with underscores to separate the longer names:
then prefix it by type or category
ORGConstantName
ORGLibrary_ConstantName
ORGLibraryType_ConstantName
ORGLibraryCategory_ConstantName
it's verbose, but it avoids clashes, and it's really clear when the constant applies only to a certain scope, type, library, or other context.
whatever you settle on, just make sure it's consistent.