Re: Proper way to create a singleton without @synchronized ?
Re: Proper way to create a singleton without @synchronized ?
- Subject: Re: Proper way to create a singleton without @synchronized ?
- From: WT <email@hidden>
- Date: Sun, 17 Apr 2011 17:17:57 -0300
On Apr 17, 2011, at 4:55 PM, Joanna Carter wrote:
> Hi WT
>
>> what happens if you need/want to subclass that class? Then you have to search for and change all the places in your code base that refer to it.
>
> Hmmm, I have a problem with the idea of subclassing singletons. Does the derived instance contain the same data as the base class; so that any reference to the derived singleton is implicitly also a reference to the base singleton?
>
> Joanna
Don't get me wrong. I too see potential problems with subclassing singletons, both conceptually and in practice. In the case of my immediate needs, the base class would only and simply be a provider of singleton-ness, so to speak, that is, the ability for a/the (sub)class to have a single instance. What that subclass actually does is up to the subclass itself.
This thread has taken a turn towards the subclassing issue because of something I wrote in a reply to Kyle but subclassable singletons are not terribly all that important to me. More important to me is to get the singleton-ness quality of a class done right, for some definition of "right." I can then turn that into a template file (in the XCode sense of templates) and cookie-cut it when I need different singleton classes for different purposes.
And, as I pointed out elsewhere, getting the singleton-ness quality of a class done right, with all its quirks, is also a learning experience. In the end, that's probably the most honest reason I can give to pursue this.
WT_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden