On Jan 10, 2009, at 6:45 AM, Alastair Houghton 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.


My personal pattern is to leave the ivars as-is. Then, for parameters, I prefix with 'a' or 'an'. Local variables are prefixed with 'the':

'value' is the name of the ivar...

- (void)incrementBy:(int)aValue
{
    int theOldValue = value;

    value = aValue;

    if (aValue != theOldValue)
        ...
}

___________________________________________________________
Ricky A. Sharp         mailto:rsh...@instantinteractive.com
Instant Interactive(tm)   http://www.instantinteractive.com



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to