skills/skills.volces.com/decorator-pattern-implementor

decorator-pattern-implementor

Installation
SKILL.md

Decorator Pattern Implementor

When to Use

You need to add responsibilities to individual objects — not to an entire class — and you want to do it dynamically, without modifying the component or generating a subclass for every possible combination of responsibilities.

Apply this skill when:

  • Subclass explosion is imminent or already present: a class needs behaviors like Logged, Cached, Validated, Compressed in varying combinations, and creating LoggedCachedValidator subclasses has become unmanageable.
  • Responsibilities are optional or withdrawable at runtime: a feature toggles on per-object, not per-class.
  • Individual objects need embellishment while other instances of the same class stay plain.
  • You cannot subclass the target: the class definition is sealed, final, or belongs to a third-party library.
  • You want to compose responsibilities incrementally — add one, try it, add another — rather than building a monolithic class.

Before starting, confirm this is Decorator and not another structural pattern:

  • Need to adapt an incompatible interface? → Use Adapter instead.
  • Need to aggregate multiple children, not wrap one? → Use Composite instead.
  • Need to change the algorithm inside the object (its "guts") rather than its visible behavior (its "skin")? → Consider Strategy instead.
  • Do you need to vary responsibilities at the class level (compile-time), not per-object at runtime? → Use inheritance directly.
Installs
3
First Seen
Apr 24, 2026
decorator-pattern-implementor from skills.volces.com