Re: Cocoa coding style (was Re: Did I reinvent the wheel?)
Re: Cocoa coding style (was Re: Did I reinvent the wheel?)
- Subject: Re: Cocoa coding style (was Re: Did I reinvent the wheel?)
- From: "I. Savant" <email@hidden>
- Date: Fri, 9 May 2008 23:25:29 -0400
A few observations about Chris's advice: Points 1 & 2 are a bit
pedantic. In no way is that meant disrespectfully (in fact I respect
Chris), but style is a matter of opinion. That opinion is dictated by
whatever lead developer of whatever job you hold says it is. If you're
lucky, you're your own employer and get to boss yourself around at
will. In any case, it's probably best to live and let live ...
(3) Avoid using "get" as a prefix on accessor methods. This means
something different in Cocoa. Instead, the name of an accessor
should just be the name of the property itself.
What Chris didn't mention is that the real importance of this is
KVC compliance (and by extension KVO). Key Value Coding relies on the
following convention:
-name
-setName:
Learn it. Live it. Love it. Call it papi and let it spank you.
(4) Use Objective-C 2 properties rather than writing all your own
accessor methods.
Again - and I apologize - but this advice is incomplete. It applies
only if a) you're using Objective-C 2 (ie, targeting Leopard) and b)
only if you don't need to do anything special in your accessor
methods, like quite efficiently flagging needsDisplay in the -
setBackgroundColor: method of a custom view, for example.
--
I.S.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden