6
6tc1
Hi all, I'm looking to create a few singleton classes - they have
similar functionality and am wondering whether it is possible to safely
inherit the Singleton pattern from another class (not an interface)?
I've noticed in all "good" implementations of the Singleton pattern,
the classes are sealed - but I'm not entirely certain why this
restriction is place on Singleton classes. Is it possible to have a
base Singleton class with some base functionality and then safely
(thread related, etc) inherit from that base class.
The best theory I can come up with for "sealing" a Singleton class is
to prevent multiple instances of that base Singleton class from
existing (through multiple classes inheriting from it) - however, I
don't see why this poses a problem - since I would never actually want
an instance of this base class - just the classes that extend from it.
Thanks,
Novice
similar functionality and am wondering whether it is possible to safely
inherit the Singleton pattern from another class (not an interface)?
I've noticed in all "good" implementations of the Singleton pattern,
the classes are sealed - but I'm not entirely certain why this
restriction is place on Singleton classes. Is it possible to have a
base Singleton class with some base functionality and then safely
(thread related, etc) inherit from that base class.
The best theory I can come up with for "sealing" a Singleton class is
to prevent multiple instances of that base Singleton class from
existing (through multiple classes inheriting from it) - however, I
don't see why this poses a problem - since I would never actually want
an instance of this base class - just the classes that extend from it.
Thanks,
Novice