Writing Code

From rootshell wiki

(Difference between revisions)
Jump to: navigation, search
(Clean Code)
(Coding guidelines)
Line 1: Line 1:
{{SuperMonkoHeader}}
{{SuperMonkoHeader}}
-
Some common practices are mentioned here, for detailed information please refer to naming and memory management sessions.
+
Some common practices are mentioned here, for detailed information please refer to [[Naming]] and [[Memory Management]] sections.
-
 
+
-
 
+
-
{{SuperMonkoHeader}}
+
-
Some common practices are mentioned here, for detailed information please refer to [http://www.rootshell.ir/wiki/Naming naming] and [[memory management]] sessions.
+
== Clean Code ==
== Clean Code ==
Line 12: Line 8:
<nowiki>#pragma mark - </nowiki><br />
<nowiki>#pragma mark - </nowiki><br />
<nowiki>#pragma mark IBAction methods </nowiki>
<nowiki>#pragma mark IBAction methods </nowiki>
 +
 +
== 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.<pre>FBConnect for a facebook related class</pre>
 +
*For method names, start with a lowercase letter and capitalize the first letter of embedded words. Don’t use prefixes.<pre>fileExistsAtPath:isDirectory:</pre>
 +
*For names of functions and constants, use the same prefix as for related classes and capitalize the first letter of embedded words.<pre>NSRunAlertPanel or NSCellDisabled </pre>
 +
*Avoid the use of the underscore character as a prefix meaning private, especially in methods. Apple reserves the use of this convention.
 +
 +
== Protocols ==
 +
 +
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.
{{SuperMonkoFooter}}
{{SuperMonkoFooter}}

Revision as of 22:51, 6 August 2010

Development

Index

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.
    fileExistsAtPath:isDirectory:
  • 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.

Protocols

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