#1 this guy obviously does not understand why global variables are problem, thats why he thinks singletons and global variables are the same thing, which is false. #2 adding factory is adding unnecesary complexity, although it sounds nice from philosophical point of view. Also #3 is false because if you are using singleton you are not passing it, so changing it to other type does nothing special to all code which uses it. Anybody who wrote any project from scratch knows that passing references (to global services) through all code is not just inefficent, ugly, and hard to maintain but also practicaly imposible (functions with 12 parameters). #4, he obviously worked too much with JUnit, so accepting another paradigm is too hard for him (why everything must be standalone object?).
"varfoo" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > 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