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:

    The course of my long life hath reached at last
    In fragile bark o’er a tempestuous sea
    The common harbor, where must rendered be
    Account for all the actions of the past.
    Henry Wadsworth Longfellow (1807–1882)

    The common idea that success spoils people by making them vain, egotistic, and self- complacent is erroneous; on the contrary, it makes them, for the most part, humble, tolerant, and kind. Failure makes people cruel and bitter.
    W. Somerset Maugham (1874–1966)