KEMBAR78
Singleton pattern | ODP
Singleton Pattern
● The singleton pattern is one of the simplest design patterns
● it involves only one class which is responsible to
instantiate itself, to make sure it creates not more than
one instance.
● it provides a global point of access to that instance.
● In this case the same instance can be used from
everywhere.
Examples
● Logger Classes
● Configuration Classes
● Accesing resources in shared mode
● Factories implemented as Singletons
Class Diagram of our Program
SingletonPattern Class
MainSingletonPattern Class
Singleton pattern
Singleton pattern

Singleton pattern

  • 1.
    Singleton Pattern ● Thesingleton pattern is one of the simplest design patterns ● it involves only one class which is responsible to instantiate itself, to make sure it creates not more than one instance. ● it provides a global point of access to that instance. ● In this case the same instance can be used from everywhere. Examples ● Logger Classes ● Configuration Classes ● Accesing resources in shared mode ● Factories implemented as Singletons
  • 2.
    Class Diagram ofour Program
  • 3.
  • 4.