• 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: Any good advice for naming parameters of init methods?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Any good advice for naming parameters of init methods?


  • Subject: Re: Any good advice for naming parameters of init methods?
  • From: Kai <email@hidden>
  • Date: Fri, 11 Jul 2008 16:29:59 +0200


On 11.7.2008, at 04:59, William Xu wrote:

Jens Alfke <email@hidden> writes:

With any naming convention, the possible problem is a conflict with a name in a
superclass. Apple's Cocoa frameworks tend to use a "_" prefix for both ivars
and private method names.

How about using "_" as postfix then? Like `this_one_'. I find google c++ guide suggests that:

 http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Variable_Names

Looks good to me.

The only disadvantage of this approach is that KVC’s direct access to your ivars_ will no longer work. KVC knows about the _ivar convention (because it is used by Apple ;-) ) and matches an _ivar to the key "ivar". It won’t for ivar_. But than again it is better anyway to have explicit accessors, I’d say.


Kai

PS and OT: _ivar is not (any more) considered portable C++ either because all names beginning with _ are reserved for compiler/library use by the standard.



--
William

http://williamxu.net9.org

... I think I'd better go back to my DESK and toy with a few common
MISAPPREHENSIONS ...
_______________________________________________

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

_______________________________________________

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


References: 
 >Any good advice for naming parameters of init methods? (From: an0 <email@hidden>)
 >Re: Any good advice for naming parameters of init methods? (From: Graham Cox <email@hidden>)
 >Re: Any good advice for naming parameters of init methods? (From: "Sean McBride" <email@hidden>)
 >Re: Any good advice for naming parameters of init methods? (From: Jens Alfke <email@hidden>)
 >Re: Any good advice for naming parameters of init methods? (From: William Xu <email@hidden>)

  • Prev by Date: Re: Learning How to Program in Objective-C
  • Next by Date: Trashing files and undo
  • Previous by thread: Re: Any good advice for naming parameters of init methods?
  • Next by thread: String Encoding problem with Unicode
  • Index(es):
    • Date
    • Thread