Design Pattern 7 (proxy pattern)

Source: Internet
Author: User

Proxy mode: provides a proxy for other objects to control access to this object.

 

The Subject class defines the common interfaces of RealSubject and Proxy, so that Proxy can be used wherever RealSubject is used.

RealSubject class, which defines the real entity represented by Proxy

Proxy class. Save a reference so that the Proxy can access the object and provide the same interface as the Subject interface, so that the Proxy can replace the object.

Subject Class

 

RealSubject class

 

Proxy class

(RealSubject =

Client call

Main (=

Running Effect

Proxy modes are generally divided into the following types:

First, remote proxy provides a local representation of an object in different address spaces. In this way, the fact that an object exists in different address spaces can be hidden.

WebService in. NET is an application instance in remote proxy mode.

Second, virtual proxy is used to create objects with high overhead as needed. It stores real objects that take a long time for instantiation.

In the browser, the download is optimized through the proxy mode.

Third, the Security Proxy is used to control the access permissions of real objects.

It is generally used when the object should have different access permissions.

Fourth, smart guidance refers to the proxy processing of another thing when calling a real object.

Related Article

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.