This repository has been archived by the owner on May 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
Coding Conventions
qvacua edited this page Jan 22, 2013
·
4 revisions
These are the coding conventions which I try to follow.
- Use Objective-C literals.
- Use boxed expressions when possible.
- Class prefix:
QM
- Use static typing as much as possible for better auto-completion.
- Expose only necessary properties and methods.
- Constants should be prefixed with a "q" for better auto-completion.
- Use
static const
, not#define
. - In test codes, I don't care...
static NSString * const qSettingsInternodeDistance = @"InternodeDistance";
static const CGFloat qSomeFloat = 0.1;
To document the code, we use the following
/**
* A Class to convert the font information
*/
@interface QMFontConverter : NSObject
/**
* String value for something.
*/
@property NSString *someStringProperty;
/**
* This method does something.
*
* @param sender The sender of something
*/
- (void)doSomething:(id)sender;
This is quite useful with "Quick Documentation" of AppCode.
For better navigation purposes, mark at least the implementation files with #pragma mark XYZ
where XYZ should be Public
, Private
or name of {protocol, super class}, eg
#pragma mark Public
- (void)publicMethod1 { NSLog(@"..."); }
- (void)publicMethod2 { NSLog(@"..."); }
#pragma mark NSObject
- (id)init { return self; }
#pragma mark NSApplicationDelegate
- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender { return NO; }
#pragma mark Private
- (void)privateMethod;
Also very useful with the "Structures" pane of AppCode.