Skip to content
This repository has been archived by the owner on May 2, 2021. It is now read-only.

Coding Conventions

qvacua edited this page Jan 22, 2013 · 4 revisions

These are the coding conventions which I try to follow.

General

Classes

  • Class prefix: QM
  • Use static typing as much as possible for better auto-completion.
  • Expose only necessary properties and methods.

Constants

  • Constants should be prefixed with a "q" for better auto-completion.
  • Use static const, not #define.
  • In test codes, I don't care...

Examples

static NSString * const qSettingsInternodeDistance = @"InternodeDistance";
static const CGFloat qSomeFloat = 0.1;

Docs

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.

Pragma Marks

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.

Clone this wiki locally