Singletons
Used when we only want one instance throughout the entire program's lifespan.
What's happening above?
Storing definition of class in memory
when
MySingleton()
is called, it checks to see if_instance
has been set, and if not, then we actually create an instance and create itResult: Only one instance is ever created
Singleton as Decorator
Last updated