Nancy Jain explains the Decorator pattern:
Decorator design pattern is a structural design pattern.
Structural design patterns focus on Class and Object composition and decorator design pattern is about adding responsibilities to objects dynamically.
Decorator design pattern gives some additional responsibility to our base class.
This pattern is about creating a decorator class that can wrap original class and can provide additional functionality keeping class methods signature intact.
I don’t use the Decorator pattern as often as I probably should, but it can be quite useful.
Comments closed