Lecture 13-Design Patterns
Lecture 13-Design Patterns
DESIGN PATTERNS
Design patterns
Singleton Pattern says that just"define a class that has only one
instance and provides a global point of access to it".
In other words, a class must ensure that only single instance should
be created and single object can be used by all other classes
Advantage of Singleton design pattern
Saves memory because object is not created at each request. Only
single instance is reused again and again.
Usage of Singleton design pattern
Singleton pattern is mostly used in multi-threaded and database
applications. It is used in logging, caching, thread pools, configuration
settings etc.
Creational-Singleton Method