• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Cocoa coding style (was loop efficiency & messages)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa coding style (was loop efficiency & messages)


  • Subject: Re: Cocoa coding style (was loop efficiency & messages)
  • From: Mark Dawson <email@hidden>
  • Date: Wed, 23 Mar 2005 09:36:28 -0800

Well, I stand correct as to the coding style for getters. I hadn't run into the coding style documentation, so I had reverted to other styles. The style guidelines are at:http://developer.apple.com/documentation/Cocoa/Conceptual/ CodingGuidelines/Articles/NamingMethods.html#//apple_ref/doc/uid/ 20001282/BCIGIJJF

As Ricky and others pointed out, if you don't follow these guidelines (http://developer.apple.com/documentation/Cocoa/Conceptual/ KeyValueCoding/Concepts/AccessorConventions.html), then key bindings won't work.

While not part of the original question, I'm glad I added that particular piece of code, as I found out that my style should change (before it became a huge issue in my project)…

Thanks!

Mark

On Mar 23, 2005, at 7:23 AM, Will Mason wrote:

Not exactly on topic but getCount is a lousy name for a method in
objective C.

Oh, don't be daft. Naming a getter method in Objecitve-C is no different from naming a getter method in any other language, and Java for instance routinely uses "get" to prefix a getter method. Just because "get" is discouraged by Apple doesn't mean we should all run from it in terror. Frankly, if a method is named getCount or count, it's equally easy to read and understand no matter what language in which it's written.

Except that messages starting with "get" in Cocoa have a specific meaning: that you're going to be passing in a pointer to something that the method is going to fill in and return. (I can't find a cite in the online docs for this, alas, or I'd point you to it.)


getCount *is* a lousy name for a method in Cocoa, unless it takes an argument into which it puts the count. You'll confuse experienced Cocoa programmers, and (once the experienced Cocoa programmer realizes that there's no reason for the inconsistency) you'll mark yourself as someone who doesn't understand the value of sticking to established coding conventions. Any street cred you get from daring to flout Apple's conventions will be lost when the person you're trying to impress realizes you don't understand why the convention is in place.

Charlton


-- Charlton Wilbur email@hidden email@hidden email@hidden

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden


This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Re: loop efficiency & messages (From: Will Mason <email@hidden>)
 >Re: loop efficiency & messages (From: Charlton Wilbur <email@hidden>)

  • Prev by Date: Re: performKeyEquivalent and arrow keys
  • Next by Date: Re: loop efficiency & messages
  • Previous by thread: Re: loop efficiency & messages
  • Next by thread: Re: loop efficiency & messages
  • Index(es):
    • Date
    • Thread