Re: Code style (was: Notify With Parameters)
Re: Code style (was: Notify With Parameters)
- Subject: Re: Code style (was: Notify With Parameters)
- From: Jeffrey Walton <email@hidden>
- Date: Thu, 02 Jun 2011 12:16:09 -0400
On Thu, Jun 2, 2011 at 4:17 AM, Conrad Shultz
<email@hidden> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 6/1/11 11:45 PM, Bing Li wrote:
>> Dear all,
>>
>> I have a question on delegate/notification techniques in Cocoa.
>
> Roland and Jens have already addressed your main issue (you can also
> look at my response to Dan Hopwood a few days ago on a related issue).
>
> But additionally you really should try to adhere to Cocoa coding
> conventions
> (http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CodingGuidelines/CodingGuidelines.html).
>
> In particular you want to avoid starting method names with capital
> letters (unless they begin with a permitted abbreviation or acronym,
> such as is the case with, e.g., many NSURL methods).
>
> Also, while not explicitly addressed in Apple's guidelines (AFAICT),
> Google's Objective-C style guide
> (http://google-styleguide.googlecode.com/svn/trunk/objcguide.xml)
> directs that spaces in method declarations be minimized. For example:
>
> - - (void) setUpNotification: (NSString *) notification withSelector:
> (SEL) methodName
>
> would be rewritten:
>
> - - (void)setUpNotification:(NSString *)notification
> withSelector:(SEL)methodName
>
> This makes it moderately easier to discern what the actual method
> arguments (and their types) are. While one could certainly say that
> Google's guidelines are "unofficial" with respect to this issue, they
> comport with Apple's own header style and I believe can be treated as
> authoritative in this case.
>
> Not only will following the guidelines now make it easier to share code
> and design APIs for use by others in the future, but it will probably
> make debugging easier (if for no other reason than people on this list
> will have to spend a couple fewer mental run loop cycles decoding what
> you intended).
>
> Just some friendly advice from someone who not that long ago was new to
> Objective-C and Cocoa and had to go through the same growing pains.
>
Slightly OT: Does Apple offer a tool similar to 'indent' for
formatting? I've never tried indent on Objective C files because it
does a miserable job on C++ source files.
Jeff
_______________________________________________
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