In an article called Root Cause of Singletons writed by Miško Hevery:
Now, there is one kind of Singleton which is OK. That is a singleton where all of the reachable objects are immutable. If all objects are immutable than Singleton has no global state, as everything is constant.
A singleton always has global state, because all of the design patterns of singleton expose a global reference to the single instance.
But why immutable singleton has no global state?
Aucun commentaire:
Enregistrer un commentaire