Structural patterns of design patterns

Source: Internet
Author: User

1. Adapter mode

1) Class of Adapter mode

   

2) The adapter mode of the object

  

3) adapter mode for the interface

The adapter for the interface is this: sometimes we write an interface with multiple abstract methods, and when we write the implementation class of the interfaces, we must implement all the methods of the interface, which is obviously sometimes wasteful, because not all methods are needed, sometimes only some, here in order to solve this problem, We introduced an interface adapter pattern, with an abstract class that implements the interface, implements all the methods, and we do not deal with the original interface, only with the abstract class, so we write a class, inherit the abstract class, rewrite the method we need.

2. Decoration mode

        

3. Proxy mode

Note: The difference between the decoration mode and the proxy mode is that the proxy mode has control over the behavior of the proxy object, while the decoration mode has no control over the behavior of the decorative object, only a little modification, and the behavior of the decorated object must be executed eventually.

4. Appearance mode

Structural patterns of design patterns

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.