Re: Name instance variables, methods and parameters.
Re: Name instance variables, methods and parameters.
- Subject: Re: Name instance variables, methods and parameters.
- From: Karl Goiser <email@hidden>
- Date: Tue, 3 Feb 2004 07:26:43 +1100
G'Day People,
Here's my take on adopting '_' for prefixing instance variables:
1) It's easy to miss when reading because there is so little to the
character - especially if the reader doesn't have 20/20 vision.
2) Unilaterally prefixing instance variables means unilaterally
prefixing them when writing which is more work and makes the code
harder to read because it adds auxiliary information.
3) You have to prefix all your instance variables lest you have to
learn/know about classes which are special cases. In that case, the
only use of prefixes is to differentiate instance variables from local
and global variables. Most people specially mark global variables and
declarations of local variables are available directly within the
method being written/reviewed. Programming in Cocoa and Objective-C is
all about object oriented programming which is about retrieving and
manipulating object state. It is thus already known that a variable in
a method must be an instance variable unless it is specially marked as
global or declared locally - that is, the default assumption about a
variable is that it is an instance variable.
4) If a variable is prefixed to indicate how it is stored, why not add
prefix information to indicate its type? Then, it's just a short road
to Hungarian notation which, thankfully, Apple and this community have
not adopted!
Regards,
Karl
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.