Proxy Pattern

In proxy pattern, a class represents functionality of another class. This type of design pattern comes under structural pattern.

In proxy pattern, we create object having original object to interface its functionality to outer world.

import abc
class Greeter(abc.ABC):
def greet(self):

class RealGreeter(Greeter):
def __init__(self, name): = name
def greet(self):
return str("Hello " +

class GreaterProxy(Greeter):
greeter = None
def greet(cls, name):
# Check if the user is authorized before calling real greater
# Check real greater is available ( resources )

if cls.greeter == None:
cls.greeter = RealGreeter(name)
else: = name
return cls.greeter.greet()

proxy = GreaterProxy()

Leave a Reply