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:

    Wilt thou have this Woman to thy wedded wife, to live together after God’s ordinance in the holy estate of Matrimony? Wilt thou love her, comfort her, honour, and keep her in sickness and in health; and, forsaking all other, keep thee only unto her, so long as ye both shall live?
    —Book Of Common Prayer, The. Solemnization of Matrimony, “Betrothal,” (1662)

    Conscious virtue is the only solid foundation of all happiness; for riches, power, rank, or whatever, in the common acceptation of the word, is supposed to constitute happiness, will never quiet, much less cure, the inward pangs of guilt.
    Philip Dormer Stanhope, 4th Earl Chesterfield (1694–1773)