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,

enter image description here

while the reference realSubject of the proxy Proxy point to the concrete RealSubject?

enter image description here

Thanks.

1

There are 1 answers

6
jaco0646 On

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.