📢 This article was translated by gemini-2.5-flash
Singleton Pattern: Object Creational Pattern
Intent
Ensure a class has only one instance and provide a global point of access to it.
Structure

Here’s the breakdown:
- Singleton: Defines an
Instanceoperation that lets clients access its unique instance. Instanceis a class operation; it might be responsible for creating its own unique instance.
Applicability
Use the Singleton pattern when:
- A class must have exactly one instance, and clients can access it from a well-known access point.
- The sole instance should be extensible by subclassing, and clients should be able to use an extended instance without changing their code.
Example
| |