Singleton

A singleton (Singleton) is a design pattern that guarantees the creation of only one instance of a class and provides a global access point to it from anywhere in the program. This is ideal for managing shared resources such as configuration or a logger, but it requires caution because it can introduce “global state” into the code. It is usually implemented with a private constructor and a static method that returns the existing object or creates a new one on first access (lazy initialization).