The Singleton Pattern

archetype Social RolesObject-Oriented Design

Categories: software-engineering

What It Brings

The name imports the concept of singular, unrepeatable identity into a domain where copying is the default operation. In mathematics, a singleton is a set with exactly one element. In social life, certain roles are structurally unique — there is one Pope, one sitting monarch, one lead conductor on the podium. The pattern maps this exclusivity onto object instantiation: there shall be exactly one instance of this class, and everyone shares it.

Key structural parallels:

Where It Breaks

Expressions

Origin Story

The Singleton pattern was codified in Design Patterns (1994) by the Gang of Four, though the practice of restricting instantiation predates the book. The mathematical term “singleton” (a set with one element) was borrowed to give the concept precision and legitimacy.

The pattern became one of the most widely used — and most widely criticized — of the original 23. Its simplicity made it the first pattern many developers learned, and its problems made it the first pattern many developers learned to avoid. The arc from “elegant solution” to “probable anti-pattern” tracks the broader maturation of the OOP community’s relationship with global state.

The “Highlander” association (“There can be only one”) entered developer culture early and stuck, giving the pattern a memorable slogan that both explains it and slightly oversells it.

References

Related Mappings