Summary of the mode of proxy mode in Java design mode

Source: Internet
Author: User

Definition: Proxy mode This design pattern is a design pattern that uses a proxy object to execute the target object's method and enhances the target object method in the proxy object .

Interpretation Definition:

1. The proxy object and the target object have a common interface;

2. Use the proxy object to execute the method in the target object;

3. Enhance the target object method in the proxy object.

Design pattern Principle: Open/Close principle ( opening to extension, closing for modification ). A good design pattern or even architecture, is to extend the new function on the basis of not modifying the original form .

The following is an understanding of the proxy pattern from a code perspective:

Elements: Handsome, beautiful, matchmaker, then the beauty shy embarrassed to speak, this time matchmaker acting as a proxy object of identity, beauty is the target object, and also need to meet the definition of the three principles.

1. First to create a common interface between beauty and matchmaker

2. Create a beauty, she realizes kindwomen this interface

3. Create a matchmaker, she also implements Kindwomen this interface (but she enhances the target of the beauty of the method)

4. Handsome debut

Summary: from 4. We can see that obviously is the matchmaker calls the method, the result is essentially the method of calling beauty, this is the simple proxy mode implementation.

Summary of the mode of proxy mode in Java design 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.