JavaScript design Pattern Classic proxy mode _javascript technique

Source: Internet
Author: User

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

<! DOCTYPE html>  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.