The singleton design pattern is perhaps the easiest of the creational design patterns to understand and to implement. The purpose of this design pattern is to ensure there is only one instance of the class, and it must be externally accessible. It is common for security-based systems to implement the singleton design pattern. An example would be a banking system that creates new account numbers. It is important that these account numbers are only generated by a single system.
We will implement the singleton design pattern simply by making the singleton class constructor private.
We will look at an example use case, the UML class diagram, and the source code that's necessary to implement the singleton design pattern for this scenario.