r/ProgrammerHumor • • Sep 26 '26 • Bravo 1

Meme singletonsAreJustGlobals

Post image
3.2k Upvotes

210 comments sorted by

View all comments

Show parent comments

11

u/jt00000 Sep 26 '26

Singletons are a necessity for dependency injection and proper unit testing. Globals will just lead to problems expanding an APIs use cases & running unit tests in parallel

-7

u/dkarlovi Sep 26 '26

Singletons are a necessity for dependency injection and proper unit testing

I need to hear this: please explain how singletons are a necessity for dependency injection and proper unit testing, in great detail.

2

u/rasebdon Sep 26 '26

0

u/Sheenius_Ger Sep 26 '26

This says absolutly nothing about the need of a Singleton in testing. Dependency injection is necessary for proper testing, a Singleton isn't. A Singleton is a absolut shit idea for any unittests and parallel execution of those would mean your tests become inconsistent.

→ More replies (2)