I consider myself having intermediate knowledge of GoF design patterns. However, I get confused when it comes to classifying those patterns into structural and behavioral patterns. I do not have any confusion about creational patterns.
From wikipedia - Decorator Pattern - In object-oriented programming, the decorator pattern is a design pattern that allows behavior to be added to an individual object, either statically or dynamically, without affecting the behavior of other objects from the same class.
From the above definition it is clear that it is about behavior, then
Thanks.
Behavioral patterns are about communication between separate objects: things like mediator, observer, chain of responsibility (even visitor, which is described as "separating an algorithm from the object structure on which it operates"). They specify how separate objects interact.
Structural patterns are about ways to compose and layer abstractions, they are things like adapter, bridge, and composite. Decorator is a technique for composing functionality, so it goes with the structural patterns.
If you need an answer in terms of your quote: The change in behavior is due to structural modification.
I.e. you "decorate" an object (via specific structuring of your class) to achieve the required behavior (via delegation)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With