Singleton in Action?

Russel Winder russel at
Sun Feb 3 15:33:15 UTC 2019

On Sun, 2019-02-03 at 14:42 +0000, Ron Tarrant via Digitalmars-d-learn wrote:
> On Sunday, 3 February 2019 at 10:28:51 UTC, Alex wrote:
> > Isn't deriving a singleton even eviler as having one? ;)
> Perhaps this was meant as rhetoric, but I think you may be right.
> This morning I was Googling "singleton replacement" and someone 
> on another forum said Factory would do the job. Anyone have 
> thoughts on that?
> (Personally, I don't see it, but I'm willing to update my 
> position based on new evidence.)

There is a lot of good stuff (both positive and negative) on Singleton here,
but there is also a bit of prejudice and bigotry. Many of the links are worth
looking through.

The good use case for Singleton is very rare, most people use them wrongly. It
is all about eschewing all global state except when it is the one and only way
of doing the design correctly. But then you have to use it correctly.

I currently have two Singletons in all my code, one I am trying to get rid of,
the other is fair enough. I think, but I'd still like to get rid of it.

Dr Russel Winder      t: +44 20 7585 2200
41 Buckmaster Road    m: +44 7770 465 077
London SW11 1EN, UK   w:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <>

More information about the Digitalmars-d-learn mailing list