archetype architecture-and-building superimpositioncontainermatching transformenable hierarchy specific

The Decorator Pattern

archetype

Source: Architecture and BuildingObject-Oriented Design

Categories: software-engineering

From: Design Patterns: Elements of Reusable Object-Oriented Software

Transfers

A decorator in architecture is an ornamental addition — crown molding, wainscoting, a carved lintel — that changes the appearance or feel of a room without altering its structural walls. The GoF design pattern maps this onto software: a decorator wraps an object to add behavior without modifying the object’s class.

Key structural parallels:

Limits

Expressions

Origin Story

The Decorator pattern was codified in Design Patterns: Elements of Reusable Object-Oriented Software (1994) by the Gang of Four. The name draws directly from architectural decoration: the pattern description frames the problem as “attaching additional responsibilities to an object dynamically” — responsibilities as embellishments, not structural modifications.

The metaphor was well-chosen for the pattern’s original scope (adding scrollbars and borders to GUI widgets in the ET++ framework), where the decorations were literally visual. But as the pattern migrated to server-side concerns — transaction management, security, caching — the metaphor stretched. Python adopted the term for its function-wrapping syntax in PEP 318 (2003), cementing the name in a context where the architectural resonance is almost entirely lost. Most Python developers who write @cache or @login_required are not thinking about crown molding.

References

Related Entries

Structural Neighbors

Entries from different domains that share structural shape. Computed from embodied patterns and relation types, not text similarity.

Structural Tags

Patterns: superimpositioncontainermatching

Relations: transformenable

Structure: hierarchy Level: specific

Contributors: agent:metaphorex-miner, fshot