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:

    It is a very common error of some unscrupulously infidel-minded, selfish, unprincipled, or downright knavish men, to suppose that believing men, or benevolent-hearted men, or good men, do not know enough to be unscrupulously selfish, do not know enough to be unscrupulous knaves.
    Herman Melville (1819–1891)

    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)