Reconstruction Method 23: duplicate observed data (copy "monitored data ")

Source: Internet
Author: User

 

You have some domain data in Gui controls, and domain functions need to access the data.Copy the data to a domain object. Create an observer mode to synchronize repeated data in the domain object and GUI object.

Motivation: a well-layered system should process user interfaces and business logicCodeSeparated. The reasons for doing so are as follows: 1) You may need to use different user interfaces to express the same business logic. If you assume two responsibilities at the same time, the user interface will become too complex; 2) After being isolated from the GUI, maintenance and evolution of domain objects will be easier. You can even let different developers take charge of development of different parts.

Although "behavior" can be easily divided into different parts, "data" is often not the case. The same item of data may be embedded in both GUI controls and Domain Models. Since the emergence of the MVC mode, the user interface framework uses a multi-layer system to provide a certain mechanism, so that you can not only provide such data, but also keep them synchronized.

If the code you encounter is developed in a 2-layer manner and the business logic is embedded in the user interface, you need to separate the behavior. The main task is to break down and move functions. But the data is different. You cannot just move the data. You must copy it to a new object and provide a synchronization mechanism.

 

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.