Singleton

Noun · Development · Origin: 1994

Definitions

  1. A Singleton is a creational design pattern that restricts a class to exactly one instance and provides a global point of access to it. No matter how many times the class is requested, the same object is returned. Typical uses include database connection pools, configuration managers, logging services, and thread pools, where multiple instances would waste resources or cause conflicts. Implementation usually involves a private constructor and a static method that lazily creates the instance on first access. While convenient, Singletons are controversial: they introduce global state, make unit testing harder because they resist mocking, and can hide dependencies. Many modern codebases prefer dependency injection to achieve single-instance behavior with better testability.

    In plain English: A programming pattern that ensures only one copy of something exists in the whole program — useful sometimes, but can make code hard to test.

Related Terms