One of the most used design patterns is Singleton. This pattern solves a very significant problem in object oriented programming and saves the lives of millions of programmers in practical programming.
The main purpose of the Singleton pattern is to deliver a single instance of object no matter how many times you instantiate it. That is, if an object is instantiated once, using the Singleton pattern you can deliver only that instance when you require it again in your code. This saves memory consumption by preventing the creation of multiple instances of an object. Thus Singleton pattern is used to improve the performance of your application.
Let's take the MySQLManager
class, which we created in the previous example. Now we are adding a single instance feature using Singleton pattern.