August 2016
Intermediate to advanced
635 pages
14h 5m
English
The Singleton pattern is perhaps the most overused pattern. It is also a pattern that has fallen out of favor in recent years. To see why people are starting to advise against using Singleton let's take a look at how the pattern works.
Singleton is used when a global variable is desirable, but Singleton provides protection against accidentally creating multiple copies of complex objects. It also allows for the deferral of object instantiation until the first use.
The UML diagram for Singleton looks like the following:

It is clearly a very simple pattern. The Singleton acts as a wrapper around an instance of the class and the singleton itself ...
Read now
Unlock full access