Proxy Design Patterns
Proxy Design Patterns
participants
Proxy (MathProxy)
o maintains a reference that lets the proxy access the real subject. Proxy may
refer to a Subject if the RealSubject and Subject interfaces are the same.
o provides an interface identical to Subject's so that a proxy can be substituted
for for the real subject.
o controls access to the real subject and may be responsible for creating and
deleting it.
o other responsibilites depend on the kind of proxy:
remote proxies are responsible for encoding a request and its
arguments and for sending the encoded request to the real subject in a
different address space.
virtual proxies may cache additional information about the real subject
so that they can postpone accessing it. For example, the ImageProxy
from the Motivation caches the real images's extent.
protection proxies check that the caller has the access permissions
required to perform a request.
Subject (IMath)
o defines the common interface for RealSubject and Proxy so that a Proxy can
be used anywhere a RealSubject is expected.
RealSubject (Math)
o defines the real object that the proxy represents.
Decorator design pattern
participants
Component (LibraryItem)
o defines the interface for objects that can have responsibilities added to them
dynamically.
ConcreteComponent (Book, Video)
o defines an object to which additional responsibilities can be attached.
Decorator (Decorator)
o maintains a reference to a Component object and defines an interface that
conforms to Component's interface.
ConcreteDecorator (Borrowable)
o adds responsibilities to the component.