Author: qmathe
Date: Wed May 7 18:19:03 2014
New Revision: 10671
URL: http://svn.gna.org/viewcvs/etoile?rev=10671&view=rev
Log:
Updated to reflect that we don't use a space between the return type and the
method name (this outlines a bit the implicit casting on the return type).
Updated method arrangment section, it is not needed anymore to declare private
methods in a class extension or category (with recent clang versions).
Modified:
web/dev/codingstyle/main.html
Modified: web/dev/codingstyle/main.html
URL:
http://svn.gna.org/viewcvs/etoile/web/dev/codingstyle/main.html?rev=10671&r1=10670&r2=10671&view=diff
==============================================================================
--- web/dev/codingstyle/main.html (original)
+++ web/dev/codingstyle/main.html Wed May 7 18:19:03 2014
@@ -59,6 +59,7 @@
*
[_README_](https://raw.githubusercontent.com/etoile/CoreObject/master/README.md)
*
[_GNUmakefile_](https://raw.githubusercontent.com/etoile/CoreObject/master/GNUmakefile)
+
## Source Code Style
### Updating Code to Current Style
@@ -388,11 +389,11 @@
Example:
- - (void) setName: (NSString *)newName;
- - (void) setTitle: (NSString *)aTitle;
- - (id) keyForOption: (CDCOption *)anOption;
- - (NSArray *) emailsForMailbox: (CDCMailbox *)theMailbox;
- - (CDCEmail *) emailForRecipients: (NSArray *)theRecipients;
+ - (void)setName: (NSString *)newName;
+ - (void)setTitle: (NSString *)aTitle;
+ - (id)keyForOption: (CDCOption *)anOption;
+ - (NSArray *)emailsForMailbox: (CDCMailbox *)theMailbox;
+ - (CDCEmail *)emailForRecipients: (NSArray *)theRecipients;
// Bad vs Correct examples to be added here
@@ -427,7 +428,7 @@
__Correct__
- - (id) title;
+ - (id)title;
__Bad__
@@ -438,12 +439,12 @@
In Ãtoilé, you should use spaces around in a method declaration in the way
depicted on the next line.
-* Plus or Minus + space + Return Type + space + First Method Keyword + space +
Type + Parameter Name + space + Next Method Keyword etc. + semicolon
-
-__Correct__
-
- - (void) setTitle: (NSString *)newTitle withEncoding: (otherType)encoding;
- + (NSString *) title: (NSString *)newTitle withEncoding:
(otherType)encoding;
+* Plus or Minus + space + Return Type + First Method Keyword + space + Type +
Parameter Name + space + Next Method Keyword etc. + semicolon
+
+__Correct__
+
+ - (void)setTitle: (NSString *)newTitle withEncoding: (otherType)encoding;
+ + (NSString *)title: (NSString *)newTitle withEncoding:
(otherType)encoding;
__Bad__
@@ -477,18 +478,18 @@
Here is the proper way to spell read and write accessors:
-* (_valueType_) _valueName_; /* this is a getter */
-* (void) set + _ValueName_: (_valueType_)parameter /* this is a setter */
+* (_valueType_)_valueName_; /* this is a getter */
+* (void)set + _ValueName_: (_valueType_)parameter /* this is a setter */
Take note, you must avoid the _get_ prefix in your getter names.
__Correct__
- - (EXAddress *) address
-
-__Bad__
-
- - (EXAddress *) getAddress
+ - (EXAddress *)address
+
+__Bad__
+
+ - (EXAddress *)getAddress
The only exception is when you're returning a value indirectly via a memory
address, use _get_ prefix.
@@ -510,57 +511,39 @@
* Class methods
* Factory methods
* Initialization methods
-* Main methods (logic, behavior related)
-* Accessors
-
-Put private methods in the implementation by declaring them in a category
named (ModuleNamePrivate).
+* Properties
+* Main methods (logic, behavior related)
+
+The method order in the implementation must be the same than in the header.
Here is an example:
-* Header
-
@interface DummyClass : MySuperclass
-
- + (Foo *) classMethods;
-
- + (id) classMethodsThatCreateObjects; /* e.g. new or newWithZone */
-
- - (id) init;
- - (id ) initWithExtraArgument: (id)extraArgument andOtherExtraArgument:
(id)otherExtraArgument;
- - (void) dealloc;
-
- /* Other instance methods */
- - (id) value; /* getter */
- - (void) setValue: (id)newValue /* setter */
+
+ /* Class and Factory Methods */
+
+ + (Foo *)classMethods;
+
+ + (id)classMethodsThatCreateObjects;
+
+ /* Initialization */
+
+ - (id)init;
+ - (id )initWithArgument: (id)anArgument;
+
+ // Equality and description methods are usually put here
+
+ /* Properties */
+
+ // The getter is just before the setter
+ - (id)value;
+ - (void)setValue: (id)newValue;
+
+ /* Main Methods */
+
+ - (void)doSomething;
@end
-
-
-* Implementation
-
- @interface DummyClass (BookmarkKitPrivate)
- - (id) myInternalStuff;
- @end
-
- @implementation DummyClass
-
- /* Methods declared in the header have their implementation put here */
- - (void) setValue: (id)newValue
- {
- return bipValue;
- }
-
- @end
-
- @implementation DummyClass (BookmarkKitPrivate)
-
- - (id) myInternalStuff
- {
- return nil;
- }
-
- @end
-
### Comments
_______________________________________________
Etoile-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/etoile-cvs