Re: How far with accessors?
Re: How far with accessors?
- Subject: Re: How far with accessors?
- From: Ondra Cada <email@hidden>
- Date: Fri, 28 May 2004 02:39:32 +0200
Jeff,
sorry I am about to be somewhat brief, but it's getting late here...
On 28.5.2004, at 1:11, Jeff Biggus wrote:
>
1. Using a setter method to dealloc an object, mixes two different
>
functions in one method. (poor isolation of functionality)
I think it all boils down to this: what we perhaps lack here is a good
and widely accepted definition of "accessor".
To me, it is the *essential minimum* needed to set (or get, of course,
but here we are focused on setters) the value. If there are other
tricks, they belong to elsewhere (i.e., to be implemented in other
methods which would use the accessors). Of course, the "essential
minimum" may be a lot of code in some cases--if it all is important
whenever the property changes, that it. On the other hand, no defaults
or similar tricks; namely, this means that
- using setter with a nil argument just removes the value. If we wanted
to set some special value, we would call the setter with the special
value for an argument. Defaults or using empty strings instead no
strings and similar tricks belong to higher level than accessors;
- especially, placeholders like "(not specified)" for a nil given for a
string belong *MUCH* higher, to the controller level -- we are speaking
model now, more or less.
I admit that I cannot find it defined explicitly in Cocoa docs. Seemed
to me natural, I guess ;)
I *think* things like how accessors are used by KVC and similar layers
somewhat support my opinion, but at the moment cannot give better
arguments.
A somewhat unrelated note: although you did not write it directly (or
perhaps I misread it?), seems to me you don't like the autoreleasing
getter. Well, searching for the accessor definition I did bump into a
*very* explicit specification that the autoreleasing getter is a
"better" technique [1] and "the recommendation" [2].
[1]
http://developer.apple.com/documentation/Cocoa/Conceptual/
AddingBehaviorToCocoa/Articles/BasicSubclassDesign.html
[2]
http://developer.apple.com/documentation/Cocoa/Conceptual/
CodingGuidelines/Articles/FrameworkImpl.html
---
Ondra Hada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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.