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 you meet a sectary, or a hostile partisan, never recognize the dividing lines; but meet on what common ground remains,—if only that the sun shines, and the rain rains for both; the area will widen very fast, and ere you know it the boundary mountains, on which the eye had fastened, have melted into air.
    Ralph Waldo Emerson (1803–1882)

    The difference between people isn’t in their class, but in themselves. Only from the middle classes one gets ideas, and from the common people—life itself, warmth. You feel their hates and loves.
    —D.H. (David Herbert)