Re: Is Apple's singleton sample code correct?
Re: Is Apple's singleton sample code correct?
- Subject: Re: Is Apple's singleton sample code correct?
- From: Ondra Cada <email@hidden>
- Date: Tue, 29 Nov 2005 15:15:23 +0100
Serge,
On 29.11.2005, at 13:11, Serge Cohen wrote:
** if the client follows the rules, the class does exactly what we
want it to do **
The client here should follow the rule of knowingly use a singleton
class, hence don't call the alloc/init, but use tha class shared...
method (this is the implicit rule set by the Cocoa framework API).
... for THEIR singletons.
Our ones is *some* cases might need to be used through alloc/init.
E.g. to co-operate properly with client code without our reach, which
was written for using normal instances, but in the conditions *we*
need it to use a singleton instead.
(<rant> Alas too many programmers--including you, it seems--keeps
forgetting in practice we very often have to use code whose sources
are unuavailable, and thus we have to cope with them the best way we
can. </rant>)
And, of course, do recall also please what I have written about that
before:
On 29.11.2005, at 10:17, Ondra Cada wrote:
... note please I do not advocate we need this all the time, quite
the contrary -- I say we need that pretty rarely, but we may
On 29.11.2005, at 13:11, Serge Cohen wrote:
There is nothing wrong about _using_ object deallocation to do
the app-quit cleanup.
There's all wrong with it. I did it, long ago. I've learnt the
hard way.
Can you be more precise on this one? (avoiding us to learn the hard
way).
I was more precise the first time:
On 29.11.2005, at 10:17, Ondra Cada wrote:
... whilst you *can* tweak dealloc to do your application
termination cleanup, you should not. It's ugly, error-prone, it
makes maintenance a bitch. If I want to see what exactly my
application with hundreds of source files in a number of lodable
bundles and subprojects does before quit, I grep for
NSApplicationWillTerminateNotification, and that's that. What would
you do, check *all* them deallocs, whether some of them may contain
more code than plain [ivar release]?
---
Ondra Čada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden