VK <schools_ring@[EMAIL PROTECTED]
> writes:
> On May 25, 3:42 pm, Lasse Reichstein Nielsen <l...@[EMAIL PROTECTED]
> wrote:
>> In a prototype based language, you
>> can create an object directly, so there is no need to introduce
>> an otherwise unnecessary type for a single object.
>
> From a clean pattern point of view it is arguable IMHO. If there is an
> object distinctly different from the generic Object then why not to
> introduce a specific constructor for it?
How is it different from a generic object? It has properties, and
that's all that really matters. The Math object does fine in this way.
No need for a constructor, because there is no need to construct
any more!
> Besides, the singleton can be the privileged consumer of other
> objects' methods where it would be more convenient to check if
> (Consumer instanceof MySingleton) rather than using some workaround
> checks.
Why check at all? Just call the method and do***ent that objects
passed here should have such a method.
(An it's not like you can't cir***vent the singleton'ness anyway,
if you really want to, or change the properties of the singleton
object).
The problem with the Singleton (anti-)pattern is that it shouldn't
be visible. If it makes sense to have a type, then there is no
reason to restrict to just one instance at the design level.
The implementation might only need one (but experience tells me
that, e.g., testing usually requires alternatives).
The singleton idea combines two concerns into one class: The behavior
of the class and that there should be a single designated instance
that an application should use.
These two concerns could just as easily be separated into two
cl*****: the class itself and a toolbox/factory class for controlling
instancing.
<URL:http://www.ibm.com/developerworks/webservices/library/co-single.html>
Hmm, guess I'm just rambling against singletons in general.
/L
--
Lasse Reichstein Nielsen - lrn@[EMAIL PROTECTED]
DHTML Death Colors:
<URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'


|