class Subject:
def request(self):
pass
class RealSubject(Subject):
def request(self):
print("RealSubject requested")
class Proxy(Subject):
def __init__(self):
self.real_subject = RealSubject()
def request(self):
self.pre_request()
self.real_subject.request()
self.post_request()
def pre_request(self):
print("Proxy pre requested")
def post_request(self):
print("Proxy post requested")
proxy = Proxy()
proxy.request()
장점:
- 보안
단점:
- 성능
- 디버깅