Singleton Implementation Issue

Tech-Archive recommends: Fix windows errors by optimizing your registry



Unless I'm misunderstanding the pattern and it's various implementations,
Singleton effectively makes the constructor unavailable to clients. The
constructor for any given class, however, is what we otherwise use [outside
of Singleton implementations] to *require* specific parameters be supplied
upon instantiation (provided of course that we've removed the default
constructor).

So my question: I want to have a Singleton implementation that requires
specific parameters to be supplied upon instantiation.

My initial shot at a reasonable answer (please provide your thoughts on
this):
1. I'll go with one of the Singleton implementations that results in lazy
instantiation.
2. Then, in order to *require* the parameters to be supplied, I'll have a
*method* named Instance() instead of a *property* of that name. The method
then defines the arguments for which clients are to supply the parameter
values upon accessing the Singleton.

Thoughts? Considerations? Perspective?

Thanks.


.



Relevant Pages

  • Re: Writing Singleton Classes
    ... cppaddict wrote: ... The first implementation needs a slight change to be thread-safe: ... There are a dozen or so Singleton articles on CodeProject; ... A review and analysis of existing C++ implementations ...
    (comp.lang.cpp)
  • Re: Singleton Implementation Issue
    ... Singleton effectively makes the constructor unavailable to clients. ... I want to have a Singleton implementation that requires ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: question: static objects in LIB
    ... > lib file seems to override whatever singleton we implement. ... The function localtimeholds its own buffer of struct tm, ... From the Alexandrescu's book show some implementations of Singleton. ...
    (microsoft.public.vc.language)
  • Re: C++ singleton pattern question
    ... You don't control initialization in the first case. ... class Singleton ... const accessor also. ...
    (comp.lang.cpp)
  • Re: Opinions on the Law Of Demeter
    ... >> product is a singleton, or else it can't know whether it ... it will be possible for multiple clients to access the same ... > implementation of the clock to be a singleton or not, ... > I think no violation of LoD. ...
    (comp.object)