Built pattern is another design pattern from the creation of design patterns category.
The features of the Singleton pattern are the following, it prevents the instantiation of a class more
than once.
So basically you cannot create two objects of the same class, that class that implements the Singleton
pattern and also provide single access to an object.
Where can you use the singleton patterns?
If, for example, your scope is to create a longer for for your actions, for the actions that your
program performs, you can create a Singleton class that will log all the actions that your program
executes.
This is the example that we will use later on in our code.
Another use case might be a report.
So, for example, you want to create a report of your unique tests.
So, for example, you don't you don't you don't want to use something, an external library that will
do that for you and you want to implement your own.
You may use the Singleton pattern to create such a report, a and also a cache.
So it doesn't make sense to have multiple objects that will store your cache, some objects in your
cache.
It might make sense to have a single instance of an object that will store everything.
And you can call this instance from many, many places in your code.
Let's take a look in the code to see how exactly we can implement the Singleton pattern.