Decorative design

I was looking at a decorator design template (I am new to the topic of design patterns) and I was wondering

  • Can a decorator interact with multiple components?
  • If A is a decorator of component B, can A have operations that B does not have?

Thanks.

+6
design design-patterns
source share
3 answers

1.) Yes
2.) Yes, this is the main point of the decorator. To add functionality to the object that it decorates.

Decorator drawing

+11
source share

Decorator simply adds functionality to the class that it decorates. Varieties like icing on a cake. You can decorate more than one component, but it looks more like Facede, although I could be wrong. The second question is - the shell adds functionality, but can also mask it

+1
source share
  • Yes
  • What else would be a decoration?
0
source share

All Articles