by, 03-09-2012 at 06:38 PM (545 Views)
Singleton pattern is considered to be a design pattern in software engineering which is used for the implementation of the mathematical singleton’s concepts. It is done by making restrictions at the instantiation of one class to 1 object. It is more beneficial in those cases when just 1 object is required to make the coordination of the actions, across the system. This concept is basically generalized to all those systems which are operating efficiently when 1 object is peresnt, or when instantiation is restricted to a specified object numbers.
- Prototype patterns, the abstract factory and builder might use singletons while doing implementation.
- Usually Façade Objects are considered as Singletons as just 1 Façade object is needed.
- Usually state objects are Singletons.
- Often Singletons are given preference as compare to the global variables as:
o Due to unnecessary variables, global name space doesn’t get polluted
o Lazy initialization as well as allocation is permitted by them however, global variables of various languages always will be consuming the resources.