Cancel changes to basic data-application Memo mode

Source: Internet
Author: User


Pattern Application Background


In the computer room charge system, there is a window to change the basic data:



Since the data was changed in the text box. Just do not click Change button. is not updated to the database. So, the Cancel button here in the Personal edition reads the original data from the database and loads it into the window again. In this collaboration, the memo mode was added to deal with this cancel button again.



How to increase the mode


The basic idea is this:

1. Place the saved Basedata (the entity name of the base data Class) as a member variable inside the memo class. And pass in the basic data to be saved when the memo class is initialized.

2, define the data that the initiator uses to create and restore the memo, assuming that the click is canceled. This class is used to recover data in the data memo and return

3, using managers to manage the resulting memos



Class diagrams such as the following:





Advantages of Using Memo mode:




1, the access details of the basic data are encapsulated and stored in the Basedatamemento, which realizes the separation of the basic data storage and recovery;

2, avoid frequent access to the database to read the basic data




Defect Considerations for Memo mode


since the memo pattern is to encapsulate objects into a memo object, when it is assumed that the data to be saved is large, this time to memory, resources are often consumed more and better than reading the resource data to the database connection. Weigh the two implementations of the "Cancel" method, and this time we use this pattern to consider when necessary.




Cancel changes to basic data-app Memo 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.