# Decorator Pattern Confidence: high Last verified: 2026-05-22 Generation: human_only ## TL;DR Attaches additional responsibilities dynamically, providing flexible alternative to subclassing. Decorators conform to the same interface, enabling transparent stacking. ## Core Explanation Example: `new CompressedStream(new EncryptedStream(new FileStream()))`. Python @decorator syntax. ES7 decorators (Stage 3). React HOC (Higher-Order Components) is a decorator pattern applied to components. Middleware pattern (Express, Koa) is a variant. ## Further Reading - [Design Patterns (Gang of Four)](undefined)