A design pattern that allows behavior to be added to objects dynamically without altering their structure by wrapping them in decorator objects. Each decorator implements the same interface as the original object and can add functionality before or after delegating to the wrapped object.
Named after the concept of decorating (adding ornaments to) something without changing its core structure, formalized in the Gang of Four book (1994). The pattern provides an alternative to subclassing for extending functionality, avoiding the 'explosion of subclasses' problem.
The Decorator pattern is like customizing a coffee order - you start with basic coffee and wrap it with decorators like 'extra shot', 'whipped cream', and 'caramel syrup', each adding its own behavior without changing the original coffee! This is how middleware works in web frameworks, where each layer adds functionality like authentication or logging.
Complete word intelligence in one call. Free tier — 50 lookups/day.