Had this interesting question being asked today and the arguments varied from Proxy to Wrapper to 开发者_运维技巧Decorator.
Thoughts?
The short description of
- Proxy: "Provide a surrogate or placeholder for another object to control access to it".*
- Decorator: "Attach additional responsibilities to an object dynamically."*
- Adapter (Wrapper): "Convert the interface of a class into another interface clients expect."*
Based on this, to me AOP looks like (a solution to the problem solved by) Decorator rather than Proxy - and definitely not Adapter.
*From the GoF book.
"the arguments varied from Proxy to Wrapper to Decorator."
Correct. That's why they give it a new name -- Aspect-Oriented Programming -- not just an OOP design pattern.
If it could be reduced to a single design pattern, it wouldn't last long in the marketplace of ideas.
The point is to take viewpoint that's a bit more broad.
精彩评论