Singleton Implementation Issue
- From: "Smithers" <A@xxxxx>
- Date: Tue, 31 Jul 2007 11:57:34 -0700
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.
.
- Follow-Ups:
- Re: Singleton Implementation Issue
- From: Samuel R . Neff
- Re: Singleton Implementation Issue
- From: Nicholas Paldino [.NET/C# MVP]
- Re: Singleton Implementation Issue
- Prev by Date: Re: how to extend OpenFileDialog ?
- Next by Date: Re: serial number (activation code)
- Previous by thread: Making a Script Repository in C#
- Next by thread: Re: Singleton Implementation Issue
- Index(es):
Relevant Pages
|