A UML class diagram for the Proxy pattern
We will now discuss the Proxy pattern with the help of the following UML diagram. As we discussed in the previous paragraph, the Proxy pattern has three main actors: the production house, Agent
, and the Actor
. Let's put these in a UML diagram and see how the classes look:
As we observe the UML diagram, you'll realize that there are three main participants in this pattern:
Proxy
: This maintains a reference that lets theProxy
access the real object. It provides an interface identical to theSubject
so thatProxy
can substitute the real subject. Proxies are also responsible for creating and deleting theRealSubject
.Subject
: It provides a representation for both, theRealSubject
andProxy
. AsProxy
andRealSubject
implementSubject
,Proxy
can be used whereverRealSubject
is expected.RealSubject
: It defines the real object that theProxy
represents.
From the data structure's perspective, the UML diagram can be represented as follows:
Proxy
: It is a class...