Chapter 15. The Proxy Pattern

The Proxy pattern is used to represent with a simpler object an object that is complex or time-consuming to create. If creating an object is expensive in time or computer resources, a Proxy allows you to postpone this creation until you need the actual object. A Proxy usually has the same methods as the full object that it represents. Once that full object is loaded, the Proxy passes on the method calls to the full object.

There are several cases where a Proxy can be useful:

  1. If an object, such as a large image, takes a long time to load

  2. If the object is on a remote machine and loading it over the network might be slow, especially during peak network load periods

  3. If the object has limited access rights. The proxy can ...

Get Java™ Design Patterns: A Tutorial now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.