• 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: A Data Object in Cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A Data Object in Cocoa


  • Subject: Re: A Data Object in Cocoa
  • From: "Michael Ash" <email@hidden>
  • Date: Sat, 10 Jan 2009 11:48:57 -0500

On Sat, Jan 10, 2009 at 7:45 AM, Alastair Houghton
<email@hidden> wrote:
> On 10 Jan 2009, at 00:11, Adam Foltzer wrote:
>
>> I've noticed a pattern in some Apple code where the instance variables are
>> all prefixed with an underscore, but the property name, and therefore the
>> accessors, are what you'd expect.
>
> Except that there's a long-standing rule that we shouldn't use leading
> underscores for either member variable names or private method names because
> names beginning with underscore are reserved for Apple's own use (even
> member variable names, IIRC).  So if you're going to use a prefix, it's
> probably best to pick something like "m" (for "member").
>
> But in general I think it's better not to prefix the names of member
> variables, and then in your initialisers, to use a different name for the
> argument.

Personally I have found that prefixing my instance variables is one of
the best things I've ever done for code clarity. Being able to
instantly tell that a particular variable is an instance variable or
not is extremely valuable, at least to me. Tastes may vary.

As for underscore being reserved, I have never been able to figure out
any consequence of a conflict with an Apple ivar name. It may cause
your source to fail to compile, but it won't cause any *binary*
compatibility problems, which is the real menace.

Mike
_______________________________________________

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

  • Follow-Ups:
    • Re: A Data Object in Cocoa
      • From: Alastair Houghton <email@hidden>
References: 
 >A Data Object in Cocoa (From: nik heger <email@hidden>)
 >Re: A Data Object in Cocoa (From: Ken Thomases <email@hidden>)
 >Re: A Data Object in Cocoa (From: "Adam Foltzer" <email@hidden>)
 >Re: A Data Object in Cocoa (From: Alastair Houghton <email@hidden>)

  • Prev by Date: Re: [commentary] The value of warnings [was: Re: A Data Object in Cocoa]
  • Next by Date: Re: Any nice way to quit a background/helper app?
  • Previous by thread: Re: A Data Object in Cocoa
  • Next by thread: Re: A Data Object in Cocoa
  • Index(es):
    • Date
    • Thread