P
proxyuser
The context of this question is actually from the book "C# 3.0 Design
Patterns" (Bishop).
She makes the point that one of the reasons you'd use Decorator is if
you can't change the original component class. On p. 17, she explains
a code example: "...this code deviates from the [original] pattern
laid out...there is no IComponent interface. This is perfectly
acceptable; the decorators can inherit directly from the component and
maintain an object of that class as well. ...However, this code does
realy on the original Component [declaring a particular method as
virtual.] If this is not the case, and we cannot go in and change the
Component class, an interface is necessary."
Well, if we can't change the Component class, then how can the
Component class implement a common interface? Conceptually, this is
the same thing as inheriting in this context. If you don't have
access to changing the class, you can't do it. What am I missing?
Patterns" (Bishop).
She makes the point that one of the reasons you'd use Decorator is if
you can't change the original component class. On p. 17, she explains
a code example: "...this code deviates from the [original] pattern
laid out...there is no IComponent interface. This is perfectly
acceptable; the decorators can inherit directly from the component and
maintain an object of that class as well. ...However, this code does
realy on the original Component [declaring a particular method as
virtual.] If this is not the case, and we cannot go in and change the
Component class, an interface is necessary."
Well, if we can't change the Component class, then how can the
Component class implement a common interface? Conceptually, this is
the same thing as inheriting in this context. If you don't have
access to changing the class, you can't do it. What am I missing?