Singleton

TwitterFacebook
Get flash to fully experience Pearltrees
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. [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] Besides, some authors state that the mathematical concept of a singleton can be implemented without this pattern, using just static methods . [ 7 ] Of course, this is only available for languages incorporating the static concept.

Singleton pattern

http://en.wikipedia.org/wiki/Singleton_pattern

Singleton Pattern & its implementation with C++

Introduction Suppose we have to use a single object of a class throughout the lifetime of an application. In C++, it is possible to declare a global object, which can be used anywhere inside the program. http://www.codeproject.com/Articles/1921/Singleton-Pattern-its-implementation-with-C