- Singleton Mechanics
- Singletons and Threads
- Recognizing Singleton
- Summary
Recognizing Singleton
Unique objects are not uncommon. In fact, most objects in an application bear a unique responsibility—why would you create two objects with identical responsibilities? Similarly, nearly every class has a unique role—why would you develop the same class twice? On the other hand, singleton classes—classes that allow only a single instance—are relatively rare. The fact that an object or class is unique does not imply that the _Singleton pattern is at work. Consider the classes in Figure 8.1.
Figure 8.1 Which classes appear to apply Singleton?
Challenge 8.4
For each class in Figure 8.1, say whether it appears to be a singleton class and why.
Solutions appear on page 364.