Search This Blog

Tuesday, November 15, 2011

Why we require to have both an Is-a and a Has-a relationship between Decorator and Component classes.

A decorator Is-a Component (inherits from the component) so that it can be used anywhere a component can (method calls etc..) A decorator Has-a Component (has a composed instance-reference) so that a particular decorator may wrap a particular component (or other decorator) instance and act as a proxy which adds behavior.

No comments:

Post a Comment