Comparison with Related Patterns
Both the Adapter and the Proxy constitute a thin layer around an object. However, the Adapter provides a different interface for an object, whereas the Proxy provides the same interface for the object but interposes itself where it can postpone processing or data transmission effort.
A Decorator also has the same interface as the object it surrounds, but its purpose is to add additional (sometimes visual) function to the original object. A Proxy, by contrast, controls access to the contained class.
Thought Question
You have designed a server that connects to a database. If several clients connect to your server at once, how might Proxies be of help?
Program on the CD-ROM
Image Proxy |
\Proxy |