From the course: Node.js: Design Patterns

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

The Proxy pattern

The Proxy pattern - Node.js Tutorial

From the course: Node.js: Design Patterns

Start my 1-month free trial

The Proxy pattern

- [Narrator] A proxy is an object that controls access to another object. For example, it is possible to call your top executive, the CEO of your company, directly and make an appointment with them. However, the CEO is very busy and in order for them to function efficiently, you would call their assistant and make an appointment with them instead. The assistant controls access to the CEO. You can think of them as the proxy for the CEO. They queue up appointments, prevent unnecessary appointments, and they even keep track of who met with the CEO. There are a number of reasons to use a proxy, but the main motivation from the design pattern has to do with expensive objects. Instead of working directly with an object that requires a lot of resources, you can work with a proxy, an object that has the exact same interface, but the proxy can delay instantiation of an expensive object and control requests made to that object. The gang of four defines the intent of a proxy as providing a…

Contents