Singleton Pattern - Common Uses

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:

    Man that is born of woman hath but a short time to live, and is full of misery. He cometh up, and is cut down, like a flower; he fleeth as it were a shadow, and never continueth in one stay.
    —“Burial of the Dead,” first anthem, Book of Common Prayer (1662)

    Human life in common is only made possible when a majority comes together which is stronger than any separate individual and which remains united against all separate individuals. The power of this community is then set up as “right” in opposition to the power of the individual, which is condemned as “brute force.”
    Sigmund Freud (1856–1939)