Overview
The name of the good or bad in the development often also do not pay much attention, after all, poor naming will not affect the program logic. But the poor naming of the hidden maintenance costs associated with large projects is quite high, which may be difficult to detect at the start of a project, and later fall into fought's maintenance dilemma. We often attach great importance to the complexity of the project logic, but can not be a good "simple" name to do well. In fact, if the simple things are not good, then make more complex things that is rubbish.
Naming conventions
Classification (category) naming
Same as the class name, plus the class name to extend and the "+"
Example: nsstring+urlencoding
Protocol (delegate) naming
Same as class naming, plus add "Delegate" suffix
Example: Replyviewdelegate
Method naming
The first letter is lowercase and the first letter of each word is capitalized
Method names use verb phrases
Example:-(void) Setuppostwithvalue: (int) value
"What to" is often randomly named as get
the beginning of the method. First get is a verb, so it's still "what to do" or "what to do". Then the Get method is not used to return an object, but it can be used for parameters.
-(Xxitem *) Getitematindex: (nsuinteger) Index //bad!! nonstandard naming -(Xxitem *) Itematindex: ( Nsuinteger) Index //Good, name clear -(void) GetItem: (Xxitem *) Outitem Atindex: (Nsuinteger The index // comparison conforms to the specification, but the second one is better.
Parameter naming
The first letter is lowercase and the first letter of each word is capitalized
Name hints for parameters to be added before each parameter
Example:
-(ID) Initwithnibname: (NSString *) Nibnameornil Bundle: (NSBundle *) Nibbundleornil-(void ) Performseguewithidentifier: (NSString *) identifier sender: (ID) Sender
Object naming
Using a modifier + type
IOS Code Specification