LearningTech

Structural

Proxy

Description

Lets you provide a substitute or placeholder for another object. A proxy controls access to the original object.

Where to use

  • Lazy initialization (Virtual Proxy).
  • \n
  • Access Control (Protection Proxy).

Real World Example

A website displays a low-res placeholder image while the high-res image downloads in the background.

Code Example

class Proxy:
    def __init__(self):
        pass

    def execute(self):
        print('Executing Proxy')