Use private keyword
The main topic of the singleton pattern is It has to block the access for create new instance from outside because It’s needed only one object.
We often use the ‘private’ keyword for solving this problem.
1 |
|
Initialzation Timing
If your system has a lot of the singleton pattern objects, then It could be too heavy to your system when It’s started.
Because Your system should initialize these objects at an once. We can solve this problem using the Lazy Initialization.