Coding Guidelines For Cocoa

There's one document I spend an unreasonable amount of time referring back to when coding that I think is worth others looking at too — Apple's “Coding Guidelines For Cocoa.” It's important to have a consistent style — especially when working with others — and Apple has made explicit a few that are used pretty inconsistently in the real world.

For example, from the “Naming Methods” section:

Don’t use “and” to link keywords that are attributes of the receiver.

So, for example:

- (void)doSomething:(id)foo andSomething:(id)bar

Is only correct when the second argument is an optional parameter for the method, not when it's an attribute of something.

There's a lot of other goodies, like what the very few acronyms it's OK to use in your code are are. Read it and refer back to it, and I promise the people you work with will thank you.

Collin Donnell @collin