Follow the example learning design pattern (8)-Adapter mode adapter (structural type)

Source: Internet
Author: User

Adapter mode is a structural design pattern

Design Intent: Transform the interface of one class into another interface that the customer wants. The adapter mode makes it possible for those classes that would otherwise not work together because of incompatible interfaces to work together.

The pattern, like the name of the adapter, is to enable the old interface to be able to glow in a youthful pattern, using a new interface to publish the existing interface.

Such a design pattern, our one version in the Enterprise information upgrade will be used frequently, some enterprises exist old interface often can not receive data, and reconstruction and cost is too high, it can only use the adapter mode, the old interface re-packaging release.

Of course, there are designs that will be used when people may not believe, but I have really experienced.

We used to adapt to the interface of China Mobile ADC management platform to use the adapter mode, that interface is also wonderful, ADC management platform by the six manufacturers, each manufacturer's interface and parameters are not the same, but we want to be compatible with six major platform manufacturers, At the beginning of the design of the processing of different manufacturers of data interface using adapter mode design, to ensure that the converted data in our system is a data structure, which greatly reduces our code workload.

This time is not on the code, I believe you can understand the adapter mode.

Summarize:

The adapter mode is a one-time fix, we want to try not to use this design pattern to solve our problem, because if we use it to show that our system may be outdated or the previous design is not good enough to refactor so that we have to use the adapter mode to provide interface to the external system.




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.