> On 26 Jan 2016, at 19:10, Jens Alfke <j...@mooseyard.com> wrote: > > >> On Jan 26, 2016, at 6:32 AM, Alex Zavatone <z...@mac.com >> <mailto:z...@mac.com>> wrote: >> >> Since we're all computery and programmy and stuff, couldn't we put together >> a little matrix of the type of variable and come up with several loose >> standards? >> The reason I ask this (am pressing on this) is that a large amount of what >> communicates to the programmer is in the naming and casing convention of the >> words used. > > There is a very longstanding convention in Objective-C — going back to the > NeXT days — to prefix instance variables with underscores. You’ll see that in > many of Apple’s headers (the ones that still list ivars in the @interface) > and in some Apple sample code. > > (There was a time when Apple was warning 3rd party developers not to do this > because of name collisions with inherited ivar names, but that’s a non-issue > with the modern Obj-C runtime.) > > I would strongly urge that anyone prefixing ivars use this convention, for > consistency. Additionally, I find that the underscore adds less visual > clutter than a letter like “m”. Your brain doesn’t see it as a letter, so it > doesn’t get in the way of reading the variable name.
I find the “_” very difficult to see and also I tend to think of it as “Apple Reserved”, which I think it used to be? > Beyond that it’s a matter of preference. I prefix static variables with “s”, > a convention that dates back to MacApp (~1988!). I don’t see any reason to > prefix function parameters or locals in general, since they’re the default, > although I sometimes use an “out” prefix for a by-reference parameter like an > NSError**. I find it much better to differentiate between, Entry Parameters, Local Variables, Ivar’s and Properties. I also use “g” for global instead of “s”. I’ve had to debug a lot of code written by other people and finding that a local name overrides an iVar after a few hours trying to figure out what its trying to do made me this way! Cheers Dave _______________________________________________ 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