Re: Accessors
Re: Accessors
- Subject: Re: Accessors
- From: Marcel Weiher <email@hidden>
- Date: Wed, 7 Aug 2002 12:00:36 +0200
On Wednesday, August 7, 2002, at 11:29 Uhr, Chris Ridd wrote:
Accessor: a method that provide access to instance variables,
and no
more.
Accessors are replacements for direct access to instance varibles.
Why
not access the instance variables directly? Because the object may
change in the future in such a way that accessing that instance
variable directly is no longer appropriate. So accessors are a way of
dealing with future change, if you're code is never actually going to
change, you wouldn't need accessors. (Note that this is different
from
*thinking* that your code is nevery going to change... ;-)
If the future change removes that instance variable, but you rewrite
the
"accessor" to synthesize a return value, what is the "accessor" called
then?
This surely breaks your simple classification scheme.
Not at all. In that case, it ceases to be an accessor. After all, the
point of accessors is that they are *methods*, in order to *hide*
wether they are just accessing an instance variable.
I am glad you brought this up: for a client, wether something is an
accessor or not does not and should not matter. For a client, it is
just a method that returns a value. Furthermore, a client shouldn't
have to distinguish between "simple collections" and "complex objects"
or whatever else in order to know what to do.
Just follow the ownership rules and you'll be fine.
Marcel
--
Marcel Weiher Metaobject Software Technologies
email@hidden www.metaobject.com
Metaprogramming for the Graphic Arts. HOM, IDEAs, MetaAd etc.
_______________________________________________
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.