Mรณdulo 27 ยท Design Patterns (All 23 GoF) โ Lecciรณn 9 de 23 ยท ~6 min
Decorator
Wrap an object to add behavior without changing it
Decorator wraps an object in another object that shares its interface and adds behavior on top. Start with a base walk price; wrap it to add a GPS surcharge; wrap that to add insurance. Each layer adds a bit and forwards the rest โ the base class never changes.
This is the structural, object-wrapping Decorator โ not the same as Python's @decorator syntax (which is a function-wrapping cousin of the same idea).