Proxy mode-when to use proxy Mode

Source: Internet
Author: User

When using an existing method, you need to improve or modify the original method. At this time, there are two ways to improve: modify the original method to adapt to the current use method, or use a "third party" method to call the original method, and control the results of the method. The first method obviously violates the principle of "open to extension and disable to modify", and modifications to the original method may blur and diversify the functions of the original class, the second method can be used to clearly classify functions and facilitate subsequent maintenance. So to some extent, the second method is a good choice! This is the proxy mode.

Proxy can be divided by purpose.

Remote Proxy: provides a Local Area Representative object for an object in a different address space. The address space can be in this machine or another machine. Remote proxy is also called ambassador ).

Virtual Proxy: creates an object with high resource consumption as needed, so that the object is created only when necessary.

Copy-on-write Proxy: a virtual proxy. Delays replication (cloning) until the client needs it.

Protection (protect or access) proxy: controls access to an object. If necessary, different users can be granted different levels of access permissions.

Cache Proxy: provides a temporary storage space for the results of a target operation so that multiple clients can share the results.

Firewall Proxy: protects the target from malicious users.

Synchronization Proxy: enables several users to simultaneously use an object without conflict.

Smart reference Proxy: provides some additional operations when an object is referenced, such as recording the number of calls to this object.

In all types of proxy modes, virtual proxy, remote proxy, smart reference proxy, and protect or access) proxy is the most common proxy mode.

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.