> On 22 May 2015, at 2:28 am, Alex Zavatone <z...@mac.com> wrote:
> 
> if you use myThing, it's not visually obvious that you're directly accessing 
> the ivar


This is where a consistent and deeply ingrained naming convention is useful. 
The leading underscore has always been Cocoa’s “way” of doing that, and with 
auto-synthesis that’s now baked in. But actually because of that, it’s less 
useful as a naming convention, because it puts you back to square 1 with 
knowing which is an ivar you added and which is a synthesised property.

Because I came to Cocoa from C++, I have long had a habit of prefixing all my 
ivars with ‘m’ (for ‘member’). Some Cocoa folks don’t like that idiom, but I 
know that any time I see an access to anything starting with ‘m’ it’s a direct 
member. Sometimes I do m_ which makes it stand out even more. A lot of sample 
code seems to encourage the use of ‘my’ for anything that’s not part of the 
framework, but it quickly becomes overloaded. Whatever you choose, stick to it, 
that’s the important thing.

(Not sure, but it might also be possible to set up syntax colouring so that 
ivars you declare are highlighted differently).

—Graham



_______________________________________________

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

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

Reply via email to