CHAPTER 4

image

Proxy Patterns

GoF Definition: Provide a surrogate or placeholder for another object to control access to it.

Concept

We want to use a class which can perform as an interface to something else.

Real–Life Example

In a classroom, when one student is absent, during roll call, his best friend may try to mimic the student’s voice to try to keep his friend from being marked as absent.

Computer World Example

Consider an ATM implementation for a bank. Here we will find multiple proxy objects. Actual bank information will be stored in a remote server. We must remember that in the real programming world, the creation of multiple instances of a ...

Get Java Design Patterns 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.