Skip to main content
Post Closed as "Needs details or clarity" by candied_orange, BobDalgleish, Greg Burghardt, 8bittree, gnat
added 267 characters in body
Source Link
Christophe
  • 80.6k
  • 11
  • 132
  • 199

https://www.baeldung.com/java-decorator-pattern

With regards I am trying to understand better the above, anddecorator pattern. I have read an article with an example implementation in java and of course, GoF book I have a curiousity.

Do I always need an abstract parent i.e.for the decorator?

For instance, in the example I have an abstract ChistmasTree and its implementation, and an abstract TreeDecorator inheriting from ?ChrimasTree. The TreeDecorator has an abstract decorator() method. Let's assume I have a totally unique override of decorate() for each and every decorator implementation. Which means : TreeTopper, Tinsel, Garland, and BubbleLights, simple needs to implement ChristmasTree. Why create an additional compilation unit under thethese circumstances?

https://www.baeldung.com/java-decorator-pattern

With regards to the above, and of course, GoF book I have a curiousity.

Do I always need an abstract parent i.e. the TreeDecorator ? Let's assume I have a totally unique override of decorate() for each and every decorator implementation. Which means TreeTopper, Tinsel, Garland, and BubbleLights simple needs to implement ChristmasTree. Why create an additional compilation unit under the circumstances?

I am trying to understand better the decorator pattern. I have read an article with an example implementation in java and of course, GoF book.

Do I always need an abstract parent for the decorator?

For instance, in the example I have an abstract ChistmasTree and its implementation, and an abstract TreeDecorator inheriting from ChrimasTree. The TreeDecorator has an abstract decorator() method. Let's assume I have a totally unique override of decorate() for each and every decorator implementation: TreeTopper, Tinsel, Garland, and BubbleLights, simple needs to implement ChristmasTree. Why create an additional compilation unit under these circumstances?

Source Link
ha9u63a7
  • 397
  • 4
  • 12

Decorator Pattern - Necessity of an abstract parent vs Default Interface method

https://www.baeldung.com/java-decorator-pattern

With regards to the above, and of course, GoF book I have a curiousity.

Do I always need an abstract parent i.e. the TreeDecorator ? Let's assume I have a totally unique override of decorate() for each and every decorator implementation. Which means TreeTopper, Tinsel, Garland, and BubbleLights simple needs to implement ChristmasTree. Why create an additional compilation unit under the circumstances?