Re: Objective-C Instance Variable Names
Re: Objective-C Instance Variable Names
- Subject: Re: Objective-C Instance Variable Names
- From: John Stiles <email@hidden>
- Date: Thu, 03 Apr 2008 11:09:14 -0700
I'd never heard the Smalltalk conventions before, but I have to admit I
really like the sound of them. I'd love to see a block of code written
to these rules to see how it plays out in practice. (ObjC or C++, that
is, not Smalltalk.)
Robert Claeson wrote:
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
------------------------------------------------------------------------
_______________________________________________
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
_______________________________________________
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