From Design Pattern by Gang of Four
Why does the reference component
of the decorator Decorator
to the decorated point to the interface Component
of the decorated,
while the reference realSubject
of the proxy Proxy
point to the concrete RealSubject
?
Thanks.
Proxy may point exclusively to its subject's interface. The GoF mentions,
Proxy
may refer to a Subject
if the RealSubject
and Subject
interfaces are the same.
But depending on implementation, a Proxy may instantiate its subject by calling a constructor, which necessitates referencing a concrete object.