How do the Proxy, Decorator, Adapter, and Bridge Patterns differ?
问题 I was looking at the Proxy Pattern, and to me it seems an awful lot like the Decorator, Adapter, and Bridge patterns. Am I misunderstanding something? What's the difference? Why would I use the Proxy pattern versus the others? How have you used them in the past in real world projects? 回答1: Proxy, Decorator, Adapter, and Bridge are all variations on "wrapping" a class. But their uses are different. Proxy could be used when you want to lazy-instantiate an object, or hide the fact that you're