October 2004
Beginner
480 pages
8h 43m
English
This chapter continues the e-commerce case study introduced in Chapter 9, “The Strategy Pattern.”
This chapter
• Illustrates how a factory can control the number of instances of an object that can ever exist, using the Singleton pattern.
• Describes the key features of the Singleton pattern.
• Introduces a variant to the Singleton called the Double-Checked Locking pattern.
• Describes some of my experiences using the Singleton pattern in practice.
The Singleton pattern and the Double-Checked Locking pattern are very simple and very common. Both are used to ensure that only one object of a particular class is instantiated. The distinction ...