Am I right in saying proxy objects are like an alias of another object / entity?
How are proxy objects used? Could anyone give a basic example?
Any replies are hugely appreciated.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
From GOF – Design Patterns book:
So a class A(proxy) can extend the B(RealObject) class or implement its interfaces.
Usually proxy do some intermediate steps between the callers and the real object without the callers knowing they were facing a proxy.
There are many more specific patterns that results from proxy concept: Decorator (add more features), Remote Proxy (hide comunication between objects), Protection Proxy (control over comunication between objects), Lazy Instantiation (postpone the loading of grow objects only when they are needed) and others.
All these Patterns don’t add extra methods to the real object but add some features to the existing methods.
I suggest you to read Giorgio Sironi example in Practical php patterns book.
For a real example Doctrine uses proxy for lazy loading of related objects.