Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best design pattern for "undo" feature [duplicate]

Tags:

Possible Duplicate:
Design Pattern for Undo Engine

In general, how do you deal with supporting an "undo" feature in your application? I have worked on web apps and desktop apps alike, and I have never really felt comfortable with any "undo" system I've made.

like image 297
tenfour Avatar asked Aug 10 '10 12:08

tenfour


People also ask

Which design pattern is useful to implement undo/redo actions?

There are two main software development patterns that are the obvious choices when dealing with operations like undo and redo: Memento and Command patterns.

What is Memento pattern used for?

Memento pattern is used to restore state of an object to a previous state. As your application is progressing, you may want to save checkpoints in your application and restore back to those checkpoints later. originator : the object for which the state is to be saved.


1 Answers

I believe it should be Command design pattern.

Here is article about multilevel Undo/Redo with Command pattern.

EDIT: Here is second about multilevel Undo/Redo with Memento pattern.

So probably it can be done with both.

like image 77
jethro Avatar answered Jan 03 '23 11:01

jethro