Views: 8.1K
Replies: 1
Archived
|
Question on Decorator PatternI am not clear why we require to have both an Is-a and a Has-a relationship between Decorator and Component classes. We can just have an Is-a relation and class Component class method using Base::Operation().
Prasanna Lakshmi, Sep 20, 2010
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.
Mar 26, 2011
|
|
Reply 1Hi,
Could you post an example implementation on your thoughts of the Decorator pattern so that I can see how you're thinking? Because I have a hard time seing how it can be accomplished with a IsA relation only. Robert Blixt, Sep 22, 2010
Suppose different related classes don't have common methods ,then in that case method prototype declaration in interface will create problem .Is it necessary to declare methods in Interface ?
Aug 03, 2010
|