开发者

Best design pattern for "undo" feature [duplicate]

This question already has answers here: Closed 12 years ago.

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 wit开发者_StackOverflow社区h any "undo" system I've made.


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.


Check out the Memento Pattern


I'd vote in favor of Command pattern over Memento. Memento pattern would be much costlier then Command patterns for Undo/Redo functionality.

Capturing and Restoring object state will be quite an expensive affair compared to just doing or undoing an action on any compatible object.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜