CHAPTER 14The Proxy Pattern

In this chapter, we look at the proxy pattern. A proxy is an object that can be used to control access to another object. It implements the same interface as this other object and passes on any method invocations to it. This other object is often called the real subject. A proxy can be instantiated in place of this real subject and allow it to be accessed remotely. It can also delay instantiation of the real subject until it is actually needed; this is especially useful if the real subject takes a long time to initialize, or is too large to keep in memory when it isn't needed. Proxies can be very helpful when dealing with classes that are slow to load data to a user interface.

The Structure of the Proxy

In its most ...

Get Pro JavaScript™ Design Patterns now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.