A proxy, in its most general form, is a class functioning as an interface to something else. The proxy could interface to anything: a network connection, a large object in memory, a file, or some other resource that is expensive or impossible to duplicate. In short, a proxy is a wrapper or agent object that is being called by the client to access the real serving object behind the scenes
Hmm !, come apparirebbe in termini di codice?
delegation refers to one object relying upon another to provide a specified set of functionalities
Questa classe ad esempio delega le sue funzionalità a un altro oggetto:
class CustomInt:
def __init__(self):
self.obj = int()
def __getattr__(self, attr):
return getattr(self.obj, attr) # Delegation
Poiché è una classe che funziona come interfaccia per qualcos'altro, posso considerarla come una classe proxy?