Skip navigation.
 
mlRe: Objective-C Instance Variable Names
FROM : Robert Claeson
DATE : Thu Apr 03 20:08:55 2008

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

Related mailsAuthorDate
mlObjective-C Instance Variable Names Richard Somers Apr 3, 18:29
mlRe: Objective-C Instance Variable Names Clark Cox Apr 3, 18:37
mlRe: Objective-C Instance Variable Names Jens Alfke Apr 3, 18:45
mlRe: Objective-C Instance Variable Names Rob Napier Apr 3, 19:58
mlRe: Objective-C Instance Variable Names Robert Claeson Apr 3, 20:08
mlRe: Objective-C Instance Variable Names John Stiles Apr 3, 20:09
mlRe: Objective-C Instance Variable Names Hamish Allan Apr 3, 20:29
mlRe: Objective-C Instance Variable Names glenn andreas Apr 3, 20:42
mlRe: Objective-C Instance Variable Names Jens Alfke Apr 3, 21:08
mlRe: Objective-C Instance Variable Names Mario Gajardo Tass… Apr 5, 02:15
mlRe: Objective-C Instance Variable Names Dennis C. De Mars Apr 6, 00:44
mlRe: Objective-C Instance Variable Names Quincey Morris Apr 6, 03:17
mlRe: Objective-C Instance Variable Names Richard Somers Apr 6, 05:20
mlRe: Objective-C Instance Variable Names Jim Puls Apr 6, 05:26
mlRe: Objective-C Instance Variable Names Scott Andrew Apr 6, 18:24
mlRe: Objective-C Instance Variable Names John Stiles Apr 7, 01:39
mlRe: Objective-C Instance Variable Names Chris Suter Apr 7, 01:49
mlRe: Objective-C Instance Variable Names Jim Correia Apr 7, 01:50
mlRe: Objective-C Instance Variable Names E. Wing Apr 7, 01:54
mlRe: Objective-C Instance Variable Names Clark Cox Apr 7, 01:58
mlRe: Objective-C Instance Variable Names Michael Ash Apr 7, 02:18
mlRe: Objective-C Instance Variable Names Jim Correia Apr 7, 03:21
mlRe: Objective-C Instance Variable Names Kyle Sluder Apr 7, 03:45
mlRe: Objective-C Instance Variable Names John C. Randolph Apr 7, 03:47
mlRe: Objective-C Instance Variable Names Scott Andrew Apr 7, 06:17
mlRe: Objective-C Instance Variable Names Jens Alfke Apr 7, 06:32
mlRe: Objective-C Instance Variable Names Graham Cox Apr 7, 07:41
mlRe: Objective-C Instance Variable Names Todd Blanchard Apr 7, 08:37
mlRe: Objective-C Instance Variable Names Kyle Sluder Apr 7, 10:45
mlRe: Objective-C Instance Variable Names Richard Somers Apr 7, 16:31
mlRe: Objective-C Instance Variable Names Jens Alfke Apr 7, 16:39
mlRe: Objective-C Instance Variable Names glenn andreas Apr 7, 17:12
mlRe: Objective-C Instance Variable Names Jim Correia Apr 7, 17:26
mlRe: Objective-C Instance Variable Names Ricky Sharp Apr 7, 22:23