Re: Objective-C Instance Variable Names
Re: Objective-C Instance Variable Names
- Subject: Re: Objective-C Instance Variable Names
- From: Robert Claeson <email@hidden>
- Date: Thu, 3 Apr 2008 20:08:55 +0200
On 3 Apr 2008, at 19:58, Rob Napier wrote:
2. Leading "m" makes you look like a C++ programmer and other ObjC
programmers will laugh at you. You can take that for what it's
worth, but
it's worth keeping in mind if you're going to work on large projects
with
other programmers. "Other ObjC programmers will laugh at you" seems
to be a
common mechanism for keeping large projects sane. Java guys use their
compiler. We use peer pressure. Which you think is a better way to
enforce
good practice will determine whether you are happier as a Java or ObjC
programmer.
As a Smalltalk programmer (although I don't get to do much Smalltalk
programming these days) I stick with the following naming convention
from the Smalltalk days:
A. Arguments are usually called something like "aName", "anAddress" etc.
B. Local variables are usually named in their generic form, eg "name".
C. Instance variables are usually named like "theName", "theAddress"
or something else that makes sense if there's the risk of mixup
between ivars and locals.
"Usually" and "makes sense" are the key phrases here.
Using leading underscores or even worse, hungarian notation, gives me
sore eyes and makes the code hard to read.
On a side note, I learned C++ back in the late 80's from a guy named
Dr Bjarne Stroustrup. He didn't use hungarian or leading underscores.
I believe both conventions were introduced much later by Microsoft, if
my memory serves me right.
Robert
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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