Difference between revisions of "Singleton pattern"

From Wiki @ Karl Jones dot com
Jump to: navigation, search
(External links)
Line 11: Line 11:
 
== See also ==
 
== See also ==
  
 +
* [[Creational pattern]]
 
* [[Design pattern]]
 
* [[Design pattern]]
 
* [[Facade pattern]]
 
* [[Facade pattern]]
Line 22: Line 23:
  
  
[[Category:Design patterns]]
+
[[Category:Software design patterns]]
 
[[Category:Software engineering]]
 
[[Category:Software engineering]]

Revision as of 13:35, 20 September 2016

In software engineering, the singleton pattern is a design pattern that restricts the instantiation of a class to one object.

Description

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 are some who are critical of the singleton pattern and consider it to be an anti-pattern in that it is frequently used in scenarios where it is not beneficial, introduces unnecessary restrictions in situations where a sole instance of a class is not actually required, and introduces global state into an application.

See also

External links