O'Reilly logo

C# 3.0 Design Patterns by Judith Bishop

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Proxy Pattern

Role

The Proxy pattern supports objects that control the creation of and access to other objects. The proxy is often a small (public) object that stands in for a more complex (private) object that is activated once certain circumstances are clear.

Illustration

A major phenomenon in the world today is the rise in popularity of community networking systems, the most prominent of which is Facebook. A session from Facebook is shown in Figure 2-4.

Proxy pattern illustration—a page in a social networking system

Figure 2-4. Proxy pattern illustration—a page in a social networking system

A feature of such systems is that many people who sign up do so only to view what others are up to and do not actively participate or add content. It might therefore be a good policy to start every newcomer with a plain page and not grant users any actual storage space or access to any facilities until they start adding friends and messages.

Another feature of these systems is that you have to first register with the system and then log on at each session. Once logged on, you have access to your friends' pages. All the actions you can perform (poke, write on walls, send gifts, etc.) originate at your browser and are sent across the network to the nearest Facebook server. The objects are the Facebook pages; the proxies are the mechanisms that allow registration and login.

Design

The design of a proxy and its players is shown in the UML diagram in Figure 2-5.

Figure 2-5. Proxy ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required