On Tue, Mar 06, 2018 at 11:46:04AM -0700, Jonathan M Davis via 
Digitalmars-d-learn wrote:
> On Tuesday, March 06, 2018 18:34:34 bauss via Digitalmars-d-learn wrote:
> > Singletons are always smelly code tbh.
> >
> > Especially in D with thread-local storage.
> >
> > I can't think of a situation where you truly need singletons in D.
> I confess that I've never really understood why some folks dislike
> singletons so much, but then again, I've only rarely found cases where
> I thought that they made sense, and I gather that some folks out there
> use the singleton pattern way too much (I've heard it suggested that
> it's because it was one of the few design patterns from the design
> pattern book that was easy).

To me, a singleton is a symptom of excessive dogmatic adherence to the
OO religion where Everything Must Be A Class No Matter What. When there
can only be one of something, it's clearly no longer a *class*, but is
either a module, a global variable, or a (set of) global function(s).

I'm curious to know what are the few cases where you think a singleton
made sense, where it wouldn't be more appropriately implemented as a
module, global variable, or global function(s).


Старый друг лучше новых двух.

Reply via email to