CODINGROUTE BLOG represents some code for daily usage.
How to create Singleton design pattern?
To create the singleton class, we need to have static member of class, private constructor and static factory method.
- Static member: It gets memory only once because of static, itcontains the instance of the Singleton class.
- Private constructor: It will prevent to instantiate the Singleton class from outside the class.
- Static factory method: This provides the global point of access to the Singleton object and returns the instance to the caller.

No comments:
Post a Comment