JS Memo Mode

Source: Internet
Author: User

Memo (Memento): captures the internal state of an object without destroying the package, and saves the state outside the object. The object can then be restored to its previously saved state.

  • Memo mode comparisons apply to classes that feature more complex features, but need to maintain or record property history, or if you need to save a property that is just a small subset of many properties, originator can revert to the previous state based on the saved memento information.
  • If you need to implement the Undo function of a command when using command mode in a system, Command mode can use Memo mode to store the state of the revocable operation.
  • Using memos allows you to mask complex objects ' internal information to other objects, and when the status of a character changes, it is possible that the state is not valid, and you can use a temporarily stored memo to restore the state.

After describing the definition of the memo pattern, let's look at the structure of the memo pattern:

There are three main types of roles in memo mode:

  • Initiator Role : records the internal state of the current moment and is responsible for creating and recovering Memo data.
  • Memo Role : Responsible for storing the internal state of the initiator object, which is provided to the initiator when the recovery is in progress.
  • Manager Role : Responsible for saving memo objects.

JS 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.