Photo by Nicholas Barbaros on Unsplash

When we need a single instance of an object, of a specific class, to exist in our application, we use the Singleton pattern. Now, the pattern itself is frowned upon in some circles and is seen as an anti-pattern.

Some of the reasons the Singleton is seen as an anti-pattern are:

  • It can be technical debt in disguise. The assumption that there will only be a need for one instance of the class during…