Writing Code

From rootshell wiki

Revision as of 22:51, 6 August 2010 by Salehi (Talk | contribs)
Jump to: navigation, search


This page belongs to Turned On Ventures Guideline Series.

Some common practices are mentioned here, for detailed information please refer to Naming and Memory Management sections.

Clean Code

To make code more managed and human readable, please group related methods with #pragma mark dialect. For example put all interface builder methods in .m files under the following lines:

#pragma mark -
#pragma mark IBAction methods

Typographic Conventions

  • The name of a class should contain a noun that clearly indicates what the class (or objects of the class) represent or do. The name should have an appropriate prefix.
    FBConnect for a facebook related class
  • For method names, start with a lowercase letter and capitalize the first letter of embedded words. Don’t use prefixes.
  • For names of functions and constants, use the same prefix as for related classes and capitalize the first letter of embedded words.
    NSRunAlertPanel or NSCellDisabled 
  • Avoid the use of the underscore character as a prefix meaning private, especially in methods. Apple reserves the use of this convention.


Define each protocol in a separate .h file. Explain what each method in protocol does, the return value(s), and etc. Distinguish optional methods with @optional tag.

HierarchyPrevious.gif Programming

Copyright Turned On Ventures 2010, turnedonventures.com

Personal tools