Hello everyone:

This is a discussion on theory and not a request for any practical help.
Please also be advised I am not trying to bash Cocoa or Objective-C; I
am simply curious why the designers of same built the language the way
they did.  Understanding theory can sometimes geometrically improve
performance.

I just read Hillegass' chapter that introduces Key-Value coding.  To
refresh everyone's memory, key-value coding is the convention that says
for every object the programmer defines, setting up a setter function
and a getter function as so:

/*  Please note that I have really shortchanged the code so as not to
waste time or space with stuff we already know will be there.  
    Please also note that Outlook capitalizes lines behind my back and
be generous...*/
NSString *myString;

-(NSString *) myString
   return myString;

- (void) setMyString:(NSString *) aString
   myString = aString;

Is considered a good idea and is also a convention that ensures that
such objects like NSArrayController can work with your code with a
minimum of additional code.  I am simplifying this horribly, I admit and
will humbly bow to correction and chastisement if I have mis-stated the
concept. 

  My question is, if this is such a necessary thing, why didn't the
designers simply design the compiler to auto-generate setter and getter
functions as per the requisite style in the first place?

Offhand I can think of one reason they might have not done so:
unintended conflicts.  Requiring the programmer to explicitly state
these functions makes sure that they run into conflicts up front and can
account for them.  

But couldn't this have been resolved (as is done in C++ when attempting
to indicate a pure virtual function) with an additional
label...something like this:

NSString *MyString = -1;  // add auto setter and getter functions

It might have saved some code on the programmer's part.

Just a thought for discussion; nothing further.

R, 
John A.M. Darnell 
Team Leader 
Walsworth Publishing Company 
Brookfield, MO 
John may also be reached at [EMAIL PROTECTED] 
  
Trivia Question:  In SciFi Channel's hit series, FARSCAPE, who played
the voice of Pilot?
Answer:  The voice of Pilot was played by Lani Tupu, the same actor who
played the villain-turned-refugee, Crais.

_______________________________________________

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