Singleton Pattern Debate

The cluster centers on discussions criticizing the singleton design pattern as equivalent to global variables, highlighting its drawbacks for testing and maintainability, while suggesting alternatives like passing instances or using dependency injection.

➡️ Stable 0.6x Programming Languages
1,694
Comments
20
Years Active
5
Top Authors
#1688
Topic ID

Activity Over Time

2007
2
2008
22
2009
20
2010
45
2011
137
2012
150
2013
80
2014
200
2015
136
2016
61
2017
75
2018
71
2019
54
2020
105
2021
107
2022
123
2023
100
2024
74
2025
130
2026
2

Keywords

FUNCTION IMO AbstractSingletonProxyFactoryBean console.log WriteLine kentonshouse.com google.com UserContentSpamChecker NullPointerException object instance variables static global pattern class variable namespace methods

Sample Comments

m0th87 Sep 21, 2010 View on HN

Why are singletons worse than static methods?

jensa1948 Apr 12, 2018 View on HN

People who use singletons deserve no better...

andix May 27, 2021 View on HN

One more reason not to make singletons.

virtue3 Mar 8, 2021 View on HN

my (very tongue in cheek) favorite description of singletons - an object oriented way to break object orientedness.

whoomp12342 Jan 18, 2023 View on HN

modern patterns, but you include a singleton??? seriously, please reply to me if you actually implemented a singleton in the past 2 years

chikere232 Feb 10, 2025 View on HN

Singletons are just globals for people who have learnt "globals are bad" but lack a deeper understanding

sagichmal Oct 1, 2021 View on HN

Singletons are globals, aren't they?

rdwallis Dec 28, 2012 View on HN

Singletons are easy to implement, simple to understand and have no performance penalties. They don't need to be defended. If they work for your project, use them.

quickben Mar 31, 2018 View on HN

Imagine your example in a singleton pattern scenario. It would be quite a performance hit.

mdiesel Dec 18, 2020 View on HN

"Oh, it's just a singleton" - me after half an hour of reading yet another implementation calling it something else.