• Intent:
    • middleman between client and actual object
  • Components
    • Subject (common inteface) ⇒ shared between proxy and actual object
    • Real subject ⇒ the actual object that is being proxied
    • Proxy ⇒ holds reference to real subject
  • Difference with decorator
    • Decorator ⇒ add new responsibilities/features to the object without changing class code (e.g., logger)
    • Proxy ⇒ Controlling access to an object
      • Controlling lifecycle of objects (e.g, lazyloading, caching proxy)
      • Auth proxy ⇒ controlling access to an object (for api endpoints use a wrapper)
  • Use cases
    • Protection proxy ⇒ controlling access to objects
    • Virtual proxy ⇒ controlling access for object creation
    • Cache proxy ⇒ controlling access for method invokation