The Proxy design pattern solves problems like:
How can the access to an object be controlled?
How can additional functionality
be provided
when accessing an object?
See Applicability section for all problems Proxy can solve.
See Solution section for how Proxy solves the problems.
-
Often it should be possible to provide
additional
functionality when accessing an (already existing) object.
"[…] whenever there is a need for a more
versatile or sophisticated
reference to an object than a simple pointer."
[GoF, p208]
-
For example, when accessing sensitive objects,
it should be possible to check that clients
have the required access rights.
-
For example, when accessing expensive objects,
it should be possible to create them on demand
(i.e., to defer their instantiation until they are actually needed)
and cache their data.
-
For example, when accessing remote objects,
it should be possible
to hide complex
network communication details
from clients.