Common Uses
- The Abstract Factory, Builder, and Prototype patterns can use Singletons in their implementation.
- Facade Objects are often Singletons because only one Facade object is required.
- State objects are often Singletons.
- Singletons are often preferred to global variables because:
- They do not pollute the global name space (or, in languages with namespaces, their containing namespace) with unnecessary variables.
- They permit lazy allocation and initialization, whereas global variables in many languages will always consume resources.
Read more about this topic: Singleton Pattern
Famous quotes containing the word common:
“For we brought nothing into this world, and it is certain we can carry nothing out.”
—Bible: New Testament St. Paul, in 1 Timothy, 6:7.
The words also appear in the Book of Common Prayer, Burial of the Dead.
“... a nation to be strong, must be united; to be united, must be equal in condition; to be equal in condition, must be similar in habits and feeling; to be similar in habits and feeling, must be raised in national institutions as the children of a common family, and citizens of a common country.”
—Frances Wright (17951852)