we have to control some hardware, due to driver’s limitation all calls shall comes from the same caller object, so i implemented as singleton pattern.
the driver might hang, in this case it has to be killed and the application shall try to initiate it again… so i modified the singleton as resurrect-able – sorry i just coined this term as i don’t know what’s the correct one.
basically its life style is like this:
not exist => singleton #1 => hang => killed => singleton #2 …
during code review my colleague said he never seen such singleton before, as he understands a singleton is THE only one during whole application lifetime….
is there such a “resurrect-able singleton” design pattern? is there some pitfalls i shall be aware?
oh i’m using C#, though i take this more a general OO design topic…
The singleton pattern doesn’t really apply here, since you said yourself more objects need to be created.
I would suggest you use something similar to a factory pattern instead:
You implement a factory such that there is only one object created at a time.