When I extend a singleton I expect it to do exactly what you are saying.
Maybe you need to rethink the way you are structuring things. I would
keep them as 2 singletons with B referencing A for vars you need the
same value on.

Im tired so im not sure if that made sense.
Jim


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Christophe Herreman
Sent: 23 March 2006 15:38
To: flashcoders@chattyfig.figleaf.com
Subject: [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

Reply via email to