Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

What is Memento design pattern?

Pragya Keshap answered on February 10, 2023 Popularity 8/10 Helpfulness 2/10

Contents


More Related Answers

  • what is design pattern
  • design pattern
  • Memento Pattern

  • What is Memento design pattern?

    0

    feature in an object. In a Memento pattern there are three

    objects:

    Originator: This is the object that has an internal state.

    Caretaker: This is the object that can change the state of

    Originator. But it wants to have control over rolling back

    the change.

    Memento: This is the object that Caretaker gets from

    Originator, before making and change. If Caretaker wants

    to Rollback the change it gives Memento back to

    Originator. Originator can use Memento to restore its own

    state to the original state.

    E.g. One good use of memento is in online Forms. If we

    want to show to user a form pre-populated with some

    data, we keep this copy in memento. Now user can

    update the form. But at any time when user wants to reset

    the form, we use memento to make the form in its original

    pre-populated state. If user wants to just save the form

    we save the form and update the memento. Now onwards

    any new changes to the form can be rolled back to the

    last saved Memento object.

    https://refactoring.guru/design-patterns/memento

    Popularity 8/10 Helpfulness 2/10 Language typescript
    Source: Grepper
    Link to this answer
    Share Copy Link
    Contributed on Feb 10 2023
    Pragya Keshap
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.