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:
“The barriers of conventionality have been raised so high, and so strangely cemented by long existence, that the only hope of overthrowing them exists in the union of numbers linked together by common opinion and effort ... the united watchword of thousands would strike at the foundation of the false system and annihilate it.”
—Mme. Ellen Louise Demorest 18241898, U.S. womens magazine editor and womans club movement pioneer. Demorests Illustrated Monthly and Mirror of Fashions, p. 203 (January 1870)
“It is a maxim among these lawyers, that whatever hath been done before, may legally be done again: and therefore they take special care to record all the decisions formerly made against common justice and the general reason of mankind.”
—Jonathan Swift (16671745)