Info
An interface for accessing a particular resource
Category of proxy: communication, logging, virtual, guarding,…
Smart Pointer implements Proxy
Motivation
- Same interface, entirely different behavior
Proxy vs Decorator
| Proxy | Decorator |
|---|---|
| provide identical interface | provide enhanced interface |
| no aggregation even no materialize objects | aggregates objects |
Summary
- A proxy has the same interface with the underline object
- To create a proxy, simple replicate existing interface of an object
- Add relevant functionality to the redefined member functions
- Different proxies (communication, caching, logging, etc.) have completely different behaviors