views:

135

answers:

4

Hi,

I have been looking at the decorator design pattern (I am new to the subject of design patterns), and I was wondering,

  1. Can a decorator interact with more than one component?
  2. If A is a decorator of component B, can A have operations that B does not have?

Thank you.

+7  A: 
RC
A: 
  1. Yes
  2. What else would the decoration be?
Peter
+1  A: 

Decorator simply adds functionality to the class it decorates. Sorta like icing on the cake. You may decorate more than one component but that sounds more like Facede though I may be wrong. The second question - the wrapper adds functionality but it also can mask it

DroidIn.net
I agree, adding functionality doesn't necessarily mean adding new operations.
Federico Ramponi
A: 

Totally agree with RC. Here is a non-wikipedia link. And this one if you like Python.

Perpetualcoder