teacher
Sign in

Proxy

Stand in for an object with the same interface to delay its creation, check permission or hide that it lives elsewhere.

20 min3 interactive

The problem it solves

Sometimes the object a client wants is awkward to touch directly:

  • It is expensive to create (a big report, an image, a database connection).
  • Not everyone may use it (permissions).
  • It lives in another process or machine (a remote service).

A proxy is a stand-in with the same interface as the real object. The client cannot tell the difference. The proxy decides whether, when and how to reach the real thing.

1 of 8