August 2009
Intermediate to advanced
281 pages
6h 50m
English
This Unified Modified Language (UML) diagram details a class design using the Singleton Design Pattern (see Figure 16-1). The following list details this pattern:
MyObject is designed as a Singleton. The constructor named MyObject() is a protected method.
The public method getInstance() is responsible for checking the protected variable named instance. If instance contains an instance of MyObject, it would simply return that instance. However, if instance is NULL, getInstance() will execute the protected MyObject() to construct a new MyObject. Then, it will store that instance of MyObject in the instance variable. Finally, it will return that instance variable.
Read now
Unlock full access