Big talk design mode note State mode (not recommended) adapter mode

Source: Internet
Author: User
State mode, which, when an object's internal state changes, allows it to change its behavior, and the object looks like it has changed its class.

State mode mainly solves the situation when the conditional expression of an object state transition is too complex. It is possible to simplify the complex judgment logic by transferring the judgment logic of the state to a series of classes representing different states.

To tell the truth, this pattern is very laborious to use, and it is not very important.

Adapter (Adapter), which transforms the interface of one class into another interface that the customer wants, the Adapter mode makes it possible to work together which classes that are inherently incompatible with the interface and cannot work together.

If you can first prevent the interface of different problems, the mismatch problem will not occur;

When the small interface does not unify the problem occurs, the time reconstructs, the problem does not enlarge;

The adaptation is only considered when it is impossible to change the original design and code.

DataAdapter is used as an adapter between a dataset and a data source to retrieve and save data. DataAdapter provides this adapter by mapping fill, which changes the data in the dataset to make it easier for data in the data source to match, and update, which changes the data in the data source to match the data in the dataset.

Big talk design mode note State mode (not recommended) adapter 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.