Have you ever done interviews for software engineers? It's interesting that when you ask them about design patterns, more than 80% will mention Singleton design pattern. Why is that? Maybe it's because it is one of the most used design patterns out there or one of the easiest to grasp. We will start our journey on creational design patterns because of the latter reason.
The Singleton pattern is easy to remember. As the name implies, it will provide you with a single instance of an object, and guarantee that there are no duplicates.
At the first call to use the instance, it is created and then reused between all the parts in the application that need to use that particular behavior.
You'll use the Singleton pattern in many different situations. For example:
When you want to use the same connection to a database to make every query
When you open a Secure Shell (SSH) connection to a server to do a few...