Today I read some text from Head First Design Pattern, it’s very interesting.
Ever play good cop, bad cop? You’re the good cop and you provide all your services in a nice and friendly manner, but you don’t want everyone asking you for services, so you have the bad cop control access to you.
Isn’t this very similar to the real life? You know there are high level people who can help you solve some problems friendly, efficiently, fairly. But you just can’t get them. All the people you faced is unfriendly, they don’t care what is your problem, they’ll cost you much time and much money, and finally give you an unfair result.
These bad people are the proxies of the high level people, they control the access to them, they handle your requests for them. If you want to meet the high level people directly, you must cross over the proxies, you’ll pay many many efforts to do that.
Wonderful design pattern! Let’s look what follows the above text in Head First Design Pattern:
…the bad cop control access to you (good cop). That’s what proxies do: control and manage access. As you’re going to see, there are lots of ways in which proxies stand in for the objects they proxy. Proxies have been known to haul entire method calls over the Internet for their proxied objects; they’ve also been known to patiently stand in the place for some pretty lazy objects.
See? The proxy pattern exists all around the computer and internet world, as well as in the real life world. The high level people designed the proxy pattern in the real world, just like some smart people designed it in the programming. I am wondering if all the high level people in this country were graduated from computer schools?
I would say the Proxy Pattern is fantastic in programming but really damn in the real world!