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:

    If music in general is an imitation of history, opera in particular is an imitation of human willfulness; it is rooted in the fact that we not only have feelings but insist upon having them at whatever cost to ourselves.... The quality common to all the great operatic roles, e.g., Don Giovanni, Norma, Lucia, Tristan, Isolde, Brünnhilde, is that each of them is a passionate and willful state of being. In real life they would all be bores, even Don Giovanni.
    —W.H. (Wystan Hugh)

    Stiller ... took part in the Spanish Civil War ... It is not clear what impelled him to this military gesture. Probably many factors were combined—a rather romantic Communism, such as was common among bourgeois intellectuals at that time.
    Max Frisch (1911–1991)