A design pattern that ensures a class has only one instance throughout the application's lifetime and provides global access to that instance. It's commonly used for managing shared resources like database connections or configuration settings.
Named after the mathematical concept of a singleton set (containing exactly one element), first documented in the Gang of Four design patterns book (1994). The pattern addresses the need for exactly one instance of certain classes, like those managing system resources.
The Singleton pattern is like having exactly one CEO in a company - there can only be one, everyone knows how to reach them, and they manage company-wide resources! However, just like in real companies, having too many 'singletons' can create bottlenecks and make testing difficult.
Complete word intelligence in one call. Free tier — 50 lookups/day.