Skip to main content

Decorator Pattern Implementor

Design PatternsDesign Patterns

Implement the Decorator pattern to attach additional responsibilities to objects dynamically, providing a flexible alternative to subclassing. Use when you need to add behaviors like logging, caching, validation, authentication, compression, or UI embellishments without creating a subclass for every combination. Addresses the subclass explosion problem through transparent enclosure — decorators conform to the component interface so clients cannot distinguish decorated from undecorated objects. Covers composition order effects and the lightweight-decorator optimization. Triggers when: adding optional behaviors to objects at runtime, wrapping streams or middleware, layering cross-cutting concerns, needing to mix and match responsibilities without combinatorial subclass growth.

Install

1. Add marketplace
/plugin marketplace add bookforge-ai/bookforge-skills
2. Install plugin
/plugin install design-patterns-gof@bookforge-skills
3. Use the skill
/decorator-pattern-implementor
CC-BY-SA · Open sourceGitHub

More from Design Patterns