• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: accessor generation???
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: accessor generation???


  • Subject: Re: accessor generation???
  • From: Michael Gersten <email@hidden>
  • Date: Mon, 15 Jul 2002 16:37:58 -0700

As someone who has been there, done that, I can assure you:

> The Cocoa books and examples, however, give me an impression of a
> different norm. Much of this stuff demonstrates limiting objects'
> access to their own member variables and using things like...
>
> [self setProp: 3];
>
> ...instead of...
>
> prop = 3;


It may not happen often, but the very first time you need to make a major change in how an ivar is used will be the LAST time you have any code directly access an ivar.

Simple accessors have one simple point: Single point of access to the data, => single place to make upgrades/changes.

Isn't that the whole point of OO design in the first place?

A class : Single point of access to how things get done
Accessors: Single point of access to how things are stored/remembered.

MVC: View as 'Output + output controller': Output controller is the single point of access to the display.
Model as 'data + data controller': Data controller is the single point of access to the data.

Yes, key/value coding makes things much nicer, no need for accessors, until you get to scalar ivars. Unless 10.1 found a way around that, (id) valueForKey: returns an ID, not a scalar, and I can't use NSNumber in math expressions. (Where's that operator overloading preprocessor?)

But yes, I use accessor generation macros, and accessor access macros. EOF practically requires that you use the key/value methods, and it has stuck (especially since the "best use" pair for non-collections is 'valueForKey' and 'addObject:toBothSidesOfRelationshipWithKey:', which I always misspell.)

--
I am a Mac OS X-Cocoa/WOF/EOF developer, and I'm available for hire. Please contact me at michael-job @ stb.nccom.com if interested. Resume at http://resumes.dice.com/keybounce
_______________________________________________
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.

References: 
 >Re: accessor generation??? (From: Phillip Mills <email@hidden>)

  • Prev by Date: Re: PBX alternative?
  • Next by Date: Re: accessor generation???
  • Previous by thread: Re: accessor generation???
  • Next by thread: Re: accessor generation???
  • Index(es):
    • Date
    • Thread