• 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: Is Apple's singleton sample code correct?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: Is Apple's singleton sample code correct?
      • From: Marco Scheurer <email@hidden>
References: 
 >Is Apple's singleton sample code correct? (From: David Gimeno Gost <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: Shawn Erickson <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: David Gimeno Gost <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: Uli Kusterer <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: David Gimeno Gost <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: Uli Kusterer <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: David Gimeno Gost <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: mmalcolm crawford <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: David Gimeno Gost <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: mmalcolm crawford <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: David Gimeno Gost <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: Christian Brunschen <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: David Gimeno Gost <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: glenn andreas <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: David Gimeno Gost <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: Ondra Cada <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: David Gimeno Gost <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: Ondra Cada <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: Serge Cohen <email@hidden>)

  • Prev by Date: Re: Message.framework
  • Next by Date: Re: Core Data Fetch request very poor performance ??!
  • Previous by thread: Re: Is Apple's singleton sample code correct?
  • Next by thread: Re: Is Apple's singleton sample code correct?
  • Index(es):
    • Date
    • Thread