Proxy Pattern:
“Proxy is a structural design pattern that lets you provide a substitute or placeholder for another object. A proxy controls access to the original object, allowing you to perform something either before or after the request gets through to the original object.”
“A credit card is a proxy for a bank account, which is a proxy for a bundle of cash. Both implement the same interface: they can be used for making a payment. A consumer feels great because there’s no need to carry loads of cash around. A shop owner is also happy since the income from a transaction gets added electronically to the shop’s bank account without the risk of losing the deposit or getting robbed on the way to the bank.”
Click on the images to see them clearly.
“In the above UML class diagram, the Proxy
class implements the Subject
interface so that it can act as substitute for Subject
objects. It maintains a reference (realSubject
) to the substituted object (RealSubject
) so that it can forward requests to it (realSubject.operation()
).”
UML Class Diagram