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:
“Unpretending mediocrity is good, and genius is glorious; but a weak flavor of genius in an essentially common person is detestable. It spoils the grand neutrality of a commonplace character, as the rinsings of an unwashed wine-glass spoil a draught of fair water.”
—Oliver Wendell Holmes, Sr. (18091894)
“Vices enter into the composition of virtues as poisons into the composition of certain medicines. Prudence and common sense mix them together, and make excellent use of them against the misfortunes that attend human life.”
—François, Duc De La Rochefoucauld (16131680)
Related Phrases
Related Words