Memo Mode of design mode

Source: Internet
Author: User

definition: captures the internal state of an object without compromising encapsulation, and saves the state outside that object. This allows the object to be restored to its previously saved state

Class Diagram:

Structure:

  • Initiator: records the internal state of the current moment and is responsible for defining which state is part of the backup scope and responsible for creating and recovering Memo data.
  • Memo: responsible for storing the internal state of the initiator object, providing the internal state required by the initiator when needed.
  • Administrative roles: manage memos, save and provide memos.

Advantages:

  • When the status of the initiator role changes, it is possible that this is a wrong change, we can use the memo mode to restore the error.
  • The status of the backup is saved outside the initiator role, so that the initiator role does not need to manage the status of each backup.

Disadvantages:

  • In practical applications, the memo mode is multi-state and multi-backup, the status of the initiator role needs to be stored in the memo object, the consumption of resources is more serious.

Application Scenarios:

If there is a need to provide rollback operations, the use of Memo mode is ideal, such as JDBC transaction operations, text editor CTRL + Z recovery, and so on.

http://blog.csdn.net/zhengzhb/article/details/7697549

Memo Mode of design 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.