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