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:

    Why does not the kitten betray some of the attributes common to the adult puss? A puppy is but a dog, plus high spirits, and minus common sense. We never hear our friends say they love puppies, but cannot bear dogs. A kitten is a thing apart; and many people who lack the discriminating enthusiasm for cats, who regard these beautiful beasts with aversion and mistrust, are won over easily, and cajoled out of their prejudices, by the deceitful wiles of kittenhood.
    Agnes Repplier (1858–1950)

    But genius is religious. It is a larger imbibing of the common heart.
    Ralph Waldo Emerson (1803–1882)