Re: Accessor methods and (auto)release: conclusion
Re: Accessor methods and (auto)release: conclusion
- Subject: Re: Accessor methods and (auto)release: conclusion
- From: Marcel Weiher <email@hidden>
- Date: Tue, 6 Aug 2002 19:51:35 +0200
On Tuesday, August 6, 2002, at 07:44 Uhr, Ondra Cada wrote:
On Tuesday, August 6, 2002, at 07:36 , Marcel Weiher wrote:
...Deallocs should not have side-effects, they should just remove the
object in question.
Notice the word *remove* in the sentence above.
Oh, so eg. all those [[NSNotificationCenter defaultCenter]
removeObserver:
self] in so many of my -deallocs are all wrong? Gee.
Notice the word *remove* in the sentence above.
I think the sentence of yours is just not true. Deallocs should have
as many sideeffects as needed for *proper removing the object in the
environment it lives* -- including things like keeping observer list
up to date, keeping any named lists (like the Window menu or whatever
similar one might have in one's applicaiton) up to date, closing
potential sockets the object might use, and who knows what more.
Sure, but using set-accessors is not a generally good pattern for doing
this. For this to be acceptable, you have to know that the accessor
will not have other side effects, which isn't a safe assumption to
make. Of course, you can have a coding style that makes sure of that,
but that doesn't make it a generally acceptable pattern.
Marcel
_______________________________________________
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.