What is Singleton Pattern?
A design pattern that restricts a class to a single instance and provides a global point of access to that instance.
The Singleton pattern ensures only one instance of a class exists throughout the application lifetime. It provides a global access point via a static method (e.g., getInstance()). The constructor is made private to prevent direct instantiation.
Common uses include database connections, logging, configuration management, and thread pools. Critics argue singletons introduce global state and make testing harder. Dependency injection is often preferred as an alternative.