The Adapter Pattern

archetype Hardware CompatibilityObject-Oriented Design

Categories: software-engineering

What It Brings

An electrical adapter lets you plug a device with one shape of prongs into a socket with a different shape. The metaphor is about physical fit — two things that should work together but can’t, because their connection points have the wrong geometry. The GoF Adapter pattern maps this onto software: a class that translates one interface into another so that incompatible components can collaborate.

Key structural parallels:

Where It Breaks

Expressions

Origin Story

The Adapter pattern was codified in Design Patterns: Elements of Reusable Object-Oriented Software (1994) by the Gang of Four. The electrical adapter metaphor was already common in engineering discourse; the GoF formalized it as a pattern with two variants (class adapter using multiple inheritance, object adapter using composition).

The metaphor’s appeal is its universality. Everyone who has traveled internationally has encountered the adapter problem. The physical experience of holding a plug that doesn’t fit, then finding a small device that solves the mismatch, maps directly onto the programming experience of integrating an incompatible library. Few design pattern names achieve this level of immediate physical recognition.

The term “impedance mismatch” — now widespread in software discourse, especially around ORMs — extends the electrical metaphor further. Where the adapter addresses shape, impedance mismatch addresses the deeper incompatibility that shape adaptation alone cannot fix.

References

Related Mappings