|
|
|
|
|
by thedudemabry
4128 days ago
|
|
I totally agree that the singleton detail is beside the article's point, but what is the modern case for singletons? It seems like singletons are now considered a synonym for global variables. What other purpose do they serve? |
|
It enabled us to decouple some code deep down in our architecture and enforce some constraints around the use of this particular piece.
When you actually need a singleton it's best to use one and call it out as such so people know what they are dealing with. Dependency injection will often be passing around a singleton everywhere without people being aware that it's a singleton and all that that means.