Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

How are proxy patterns used in design patterns?


Asked by Elliott Choi on Dec 02, 2021 FAQ



Design Patterns - 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.
Keeping this in consideration,
According to GoF definition of proxy design pattern, a proxy object provide a surrogate or placeholder for another object to control access to it. A proxy is basically a substitute for an intended object which we create due to many reasons e.g. security reasons or cost associated with creating fully initialized original object.
Just so, Decorator Design Pattern - A decorator implementation can be the same as the proxy however a decorator adds responsibilities to an object while a proxy controls access to it. Security Proxies that controls access to objects can be found in many object oriented languages including java, C#, C++.
Also Know,
Remote Proxy. In distributed object communication, a local object represents a remote object (one that belongs to a different address space). The local object is a proxy for the remote object, and method invocation on the local object results in remote method invocation on the remote object.
In respect to this,
Upon receiving a request from a client, the proxy creates a real service object and delegates all the work to it. The proxy disguises itself as a database object. It can handle lazy initialization and result caching without the client or the real database object even knowing. But what’s the benefit?