Kind of flamebaity, but I'll bite.

I read that article, but this is just one man's opinions. I'm not saying he's 
wrong, but some of his points largely depend on the usage of the singleton 
itself (specifically #4). #2 kind of sounds like bullshit to me too. Sure, you 
can split a singleton into two classes, fine, one for creation and one for the 
class itself. I just don't see the point. Single responsibility deals with 
required changes. I don't see how the "singleton" aspect of the class would 
ever require a change (correct me if I'm wrong).

In fact, if you look at a lot of windowing toolkits for operating systems, you 
will see singleton usage scattered throughout.

Just a few I can think of offhand in Apple's Cocoa (a beautifully designed 
framework in my opinion):

Color panel
Font panel
...in fact, all panels
Application
User Defaults

It seems to me (because I've never run into any problems) that careful use of 
singletons is an okay thing to do. I agree that alot of people overuse them and 
try to force everything and anything into a singleton. I don't agree with that. 
I just think they have a place.

Scott

-----Original Message-----
From:   [EMAIL PROTECTED] on behalf of varfoo
Sent:   Thu 3/23/2006 5:42 PM
To:     Flashcoders mailing list
Cc:     
Subject:        Re: [Bulk] [Flashcoders] Extending a singleton

Hey,

It's not considered good practice to use singetons.  For reasons why, here's
a good article:
http://blogs.msdn.com/scottdensmore/archive/2004/05/25/140827.aspx

I don't think the protected keyword exists in AS2, but if you have AS3, I'd
trying using the protected keyword for the singleton's superclass
constructor.  I'd recommend trying this as an experiment only.

-vf

----- Original Message ----- 
From: "Christophe Herreman" <[EMAIL PROTECTED]>
To: <flashcoders@chattyfig.figleaf.com>
Sent: Thursday, March 23, 2006 7:38 AM
Subject: [Bulk] [Flashcoders] Extending a singleton


> Hi guys,
>
> I was wondering if anyone of you ever had a situation where it would be
> good to extend a singleton. The first question is: Is it good practice or
> should it be avoided at all cost?
>
> Anyway, I have been trying to extend one, but the problem is that instance
> variables are not accessible in the class that extends the singleton (and
> which is also a singleton).
>
> So for instance, take a class A that has a "properties" instance variable
> that holds key/value pairs. That var is initialized in the constructor.
>
> A.getInstance() gives me the single instance.
>
> B extends A, and B.getInstance() gives me the single instance of B. But
> since it extends A, A's constructor is called (although it is private, a
> camouflaged protected in AS2) and the properties var is instantiated
> again. Get the picture? B will have a properties instance var but it will
> not be the same as the one in the singleton of A.
>
> Am I overlooking something very obvious here or is this actually hard to
> accomplish? I changed it from inheritance to using A.getInstance()
> internally which works; but now I have to add wrapper methods for every
> method in A/ /I want to make available.
>
> thx in advance,
> Christophe
> _______________________________________________
> Flashcoders@chattyfig.figleaf.com
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com



_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to