Lesson
Vocabulary: Decorator
Vocabulary after construction: Decorator
The previous exercise began with Expected Behavior and design pressure, not with this name.
The structure that emerged is traditionally called Decorator.
What the reasoning established
- Stable role: Payment exposes one pay operation; wrappers expose the same role.
- Change pressure: Logging/retry/metrics-like behavior can be stacked independently.
- Ownership/lifetime when relevant: The composition root chooses wrapper order.
- Structural consequence: Each wrapper contains another object of the same behavioral role.
- Runtime topology: pre-behavior → delegate → post-success behavior.
Nearby distinction
Proxy: Decorator composes optional behavior around the same capability; Proxy primarily controls access, identity, location, or lifecycle.
Simplify
Ask whether any abstraction can be removed while preserving the original acceptance behavior and design-stress property. If yes, prefer the simpler design.
Use the pattern name to communicate a structure you can already justify. Do not use the name as a recipe that replaces requirements analysis.
Sign in with an enabled provider to save your lesson progress.
Sign in to track progress
Loading sign-in options…