I didn't notice the Xcode syntax-coloring of the instance variables -- I'll have to try using that.

There's another solution besides naming conventions. I've been through most of them -- underscore prefix or postfix, prefix with "m" etc. I generally don't find naming conventions very satisfactory. It seems like I'm trying to encode something into the name that should be evident from the syntax of the language or the context the variable is used in.

So the solution I am toying with, which I think most people won't like because it is quite verbose, harkens back to the old days of programming on the Mac. If you ever used the MacApp application framework (in its original incarnation) you used Object Pascal, and in Object Pascal all instance variables had to be referenced as members of "SELF", so for instance you'd have to write something like "SELF.myVariable := 2;"

When the framework was converted to C++, one of the complaints that some MacApp programmers had was that the C++ syntax would be less clear in particular regarding instance variables, where you could write "myVariable = 2;" and it wasn't clear whether "myVariable" was an instance variable or not. The Object Pascal syntax always made it clear whether the variable was an instance variable without having to refer back to the object declaration.

It was pointed out to these people that you could just as easily use the equivalent "this->myVariable = 2;" I believe the MacApp code itself made heavy use of this convention. This mollified some Object Pascal fans.

I'm toying with doing this in my new project, just because I dislike coding properties like this into the name. I'm naming my instance variables anything I want to and then consistently referring to them with self->myVariable (to access the raw ivar) or self.myVariable if I want to use the accessor.

So far it seems to be OK, except that I don't particularly like the looks of it when used as the target of a message (as in "[self->target method];") although I don't have a rational reason for that opinion.

- Dennis D.
_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to