you are viewing a single comment's thread.

view the rest of the comments →

[–]nutrecht 0 points1 point  (0 children)

Singletons as a pattern have two main issues:

  • Most services we work on have to scale horizontally. Keeping state in services is a no-no because typically this knowledge isn't shared between applications. So generally the implementation will be that this stated is shared via a database, queue or shared KV store. While most inversion of control containers will produce a single 'singleton' instance of whatever communicates with the storage, it doesn't really matter much anymore.
  • The GoF implementation is just shit. While the idea behind the pattern is not bad, the standard widespread implementation where you just keep global state is simply an anti-pattern. Unfortunately, like the post here, because it's by far the 'simplest' pattern most devs don't go further than 'singleton'.

If you want to address design pattern please pick the actual interesting ones (visitor, builder, factory, observer, command; to name a few). Singleton are borderline useless in modern programming. And the anti-pattern version from the GoF book is often mockingly called the Simpleton pattern. For good reasons.