January 2019
Intermediate to advanced
512 pages
14h 5m
English
The Singleton pattern enforces the uniqueness of an object; only one instantiation of a particular object can exist in the entire program.
In a poorly designed program, a Singleton can be used as a substitute for a global variable. To justify its use, there have to be additional reasons for the uniqueness of the object. These reasons can reflect the nature of the reality that is modeled by the program (one car per driver and one Sun in the solar system) or an artificially imposed design restriction (one central source of memory for the whole program). In either case, the programmer should consider how likely it is that the requirements ...