This chapter covers the Singleton pattern.
GoF Definition
It ensures that a class has only one instance and provides a global point of access to it.
Concept
Let’s assume you have a class called A and you need to create an object from it. Normally what do you do? You guess it right; you simply use the following line of code: A obA = new A();
But let’s look at it closely. If you keep using the new keyword ten more times, you’ll have ten more objects. Right? But in a real-world scenario, unnecessary object creation is a big concern ...