Singleton Pattern

In software engineering, the singleton pattern is a design pattern that restricts the instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system. The concept is sometimes generalized to systems that operate more efficiently when only one object exists, or that restrict the instantiation to a certain number of objects. The term comes from the mathematical concept of a singleton.

There is criticism of the use of the singleton pattern, as some consider it an anti-pattern, judging that it is overused, introduces unnecessary restrictions in situations where a sole instance of a class is not actually required, and introduces global state into an application.

In C++ it also serves to isolate from the unpredictability of the order of dynamic initialization, returning control to the programmer.

Read more about Singleton Pattern:  Common Uses, Implementation, Example, Prototype-based Singleton, Example of Use With The Factory Method Pattern, Drawbacks

Famous quotes containing the words singleton and/or pattern:

    When the sword of rebellion is drawn, the sheath should be thrown away.
    quoted in letter, Aug. 6, 1775, by painter John Singleton Copley on the subject of the American Revolution. British proverb.

    Why it was that upon this beautiful feminine tissue, sensitive as gossamer, and practically blank as snow as yet, there should have been traced such a coarse pattern as it was doomed to receive; why so often the coarse appropriates the finer thus, the wrong man the woman, the wrong women the man, many years of analytical philosophy have failed to explain to our sense of order.
    Thomas Hardy (1840–1928)