Decorator
Adds behavior to an individual object dynamically, by wrapping it, without altering the behavior of other instances of the same class.
Why we need this / what value this brings
Adds behavior to specific instances without subclassing every combination of behaviors (which explodes combinatorially).
When to use this
You need to add cross-cutting behavior (logging, caching, auth checks) around an object's existing methods, optionally and composably.
How to use or implement this
Wrap the original object in another object implementing the same interface, adding behavior before/after delegating to the wrapped instance — middleware is this pattern applied to request handlers.
Research questions
- Middleware chains (auth check, logging, rate limiting wrapped around a request handler) are a decorator pattern in practice — is that how Localz's backend middleware is structured?
Empty folder — drop notes, links, and findings here as you research.