Applied Design Patterns with Java
Structural :: Proxy (207) {C ch 15}
Example - UML : Display
Example - Java :: Patterns\Structural\Proxy
Pattern Concept: to represent with a simpler, lightweight object an object that is complex or time-consuming
to create. The simpler object is a temporary subsitute for the actual object.
Issues and Consequences of the Proxy pattern include:
- A Proxy is useful for objects with large memory footprints and significant
load or transfer times, remote objects on a network that are unavailable or slow to open, and for objects with
controlled access (the Proxy validates the access rights to the actual object);
- A Proxy is useful for objects employed in a 'Copy-on-Write' scenario.
Only when the object is changed is the actual object updated;
- Both the Adapter
and
Proxy provide
a thin layer around an object, but the Adapter exposes another interface but the Proxy provides the same interface;
- A Decorator provides the same interface to its contained object and adds new
functionality to an object, but the Proxy does not add any new methods, it simply controls access to the
contained object.
The example Java program is named 'ProxyDisplay'. The UML
diagram is above, and the list of Java files is below:
Catalog Structural Prev Next