开发者

I need a design pattern to provide undo functionality to my program

开发者 https://www.devze.com 2023-01-30 04:35 出处:网络
I need a design pattern to provide undo functionality to my program. I\'ve already used Memento, but I need another for my 开发者_Go百科coursework.The command pattern is the classic pattern for an und

I need a design pattern to provide undo functionality to my program. I've already used Memento, but I need another for my 开发者_Go百科coursework.


The command pattern is the classic pattern for an undo model.

basically encapsulate each action in an object (the command) and then make each command able to perform the reverse action. Keep a list of the commands as they are applied and to undo perform the reverse action on the list in reverse.

an example of using the command pattern for undo is here, although that was simply the first result from a google of 'command pattern for undo'

0

精彩评论

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