Singleton pattern in D

David Ferenczi raggae at ferenczi.net
Fri May 11 23:23:06 PDT 2007


> An interesting read. Thank you.

I'll try to summerise the article:

1. Singleton is evil.
2. Everyone, who uses singleton, is a beginner (or nerd?) and doesn't
understand the OO paradigm.
3. There are many problems with singletons, see section "Get to the Point,
Already".
4. If you want to use singleton, use a static class or a factory instead.

IMO the problems with singleton implementations are valid, but he forgets to
mention that exactly the same applies for static classes. Static classes
are just more effective (you save a function call) and syntactically nicer
(in the class itself, and also wehne calling). But is there really more?
Are singletons really so evil, that worth bashing? And can the factory
pattern be applied everywhere, where you need a singleton (static
availability, only one instance)? I'm not sure.

Do I miss something?

Regards,
David





More information about the Digitalmars-d-learn mailing list