🌱Aadam's Garden

Search

Search IconIcon to open search

Proxy Pattern

Last updated Jul 30, 2022

Source:: Software Design Patterns - Best Practices for Software Developers


Definition

A mechanism to provide a surrogate or placeholder for another object to control access to it.

The Proxy Pattern uses a Proxy to intercept and control interactions to target objects.

The literal definition of proxy is the authority to represent someone else. In a proxy pattern setup, a proxy is responsible for representing another object called the subject in front of clients. The real subject is shielded from interacting directly with the clients.

When to use

  • To access remote objects over the internet
  • To protect a subject from clients not authorized to access it
  • To stand in place of an object that may be expensive to create and delay the object’s creation till it is accessed
  • To cache queries or results from subject for clients

# Resources