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 common knowledge to every schoolboy and even every Bachelor of Arts,
    That all sin is divided into two parts.
    One kind of sin is called a sin of commission, and that is very
    important,
    Ogden Nash (1902–1971)

    What chiefly distinguishes the daily press of the United States from the press of all other countries is not its lack of truthfulness or even its lack of dignity and honor, for these deficiencies are common to the newspapers everywhere, but its incurable fear of ideas, its constant effort to evade the discussion of fundamentals by translating all issues into a few elemental fears, its incessant reduction of all reflection to mere emotion. It is, in the true sense, never well-informed.
    —H.L. (Henry Lewis)