CHAPTER 14 Ensuring Correct Implementation of the Proxy Pattern

WHAT’S IN THIS CHAPTER?            

  • Common uses of the Proxy Pattern
  • Using a pre-fetching proxy to improve the responsiveness of a web page
  • Using test-driven development to create a proxy
  • Deducing the internal workings of a proxy without breaking data encapsulation

WROX.COM CODE DOWNLOADS FOR THIS CHAPTER

You can find the wrox.com code downloads for this chapter at www.wrox.com/go/reliablejavascript on the Download Code tab. The files are in the Chapter 14 download and individually named according to the filenames noted throughout this chapter.

If you are an American, your entire life is literally governed by the Proxy Pattern. Although we live in a democracy, it is a representative democracy: We do not make laws directly but elect people who create laws on our behalf. We believe (rightly or wrongly) that our proxies in Congress and the White House can manage the lawmaking process better than we could. They have the time to become experts in national defense, healthcare, and other areas. We don’t. If every little issue were decided by plebiscite, we would accomplish nothing else.

When the time comes to interpret those laws, we usually hire another proxy: an attorney who is an expert in the interpretation and navigation of the relevant laws.

In software design, it is sometimes useful to create a proxy object to manage access to an underlying object (called the real subject). It acts as an expert attorney, allowing ...

Get Reliable JavaScript: How to Code Safely in the World's Most Dangerous Language now with O’Reilly online learning.

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