First, the concept of Agent mode
Description: As the name implies is to use a class to replace another class to perform the method function, this pattern is somewhat similar to the decoration pattern, not the same, the proxy mode is to initialize the proxy object class instead of the client, and the decoration mode is implemented by the interface or the initial adorner parameter reference.
Explanation: Housing intermediary, can agent to help sellers to sell the house to buyers, the middle seller said to sell the price can be, buyers can also propose their own to buy the room type, intermediary can help deal with intermediate links. Finally the deal was reached. Intermediary can be a lot of home sales agent, and can act as an agent for rent matters.
Second, the role of agent model and matters needing attention
Mode function:
1, the remote agent (an object to the different space objects for local proxy)
2, virtual agent (as needed to create expensive objects such as rendering the page temporarily replace the real map)
3, the Security agent (Control verification object access rights)
4, intelligent guidance (Invoke object agent to deal with other things such as garbage collection mechanism)
Precautions:
1, can not abuse the agent, sometimes just to increase the complexity of the code
Third, the agent mode Code and actual combat summary