# Singleton Pattern Confidence: high Last verified: 2026-05-22 Generation: human_only ## TL;DR Ensures a class has only one instance and provides global access. Used for shared resources: database connections, config, logging. Modern criticism: hidden global state, testing difficulty. ## Core Explanation Implementation: private constructor, static getInstance(). Thread-safe: double-checked locking, static initializer, or enum (Java). In JavaScript: module-level variable (modules are singletons by default). Dependency injection is often preferred over Singleton today. ## Further Reading - [Design Patterns (Gang of Four)](undefined)