Implementing the command pattern

后端 未结 2 1738
生来不讨喜
生来不讨喜 2021-01-01 22:52

I am in the design process of an application, and I would like to use the command pattern for undo/redo purposes. I did some research into the command pattern but the only t

相关标签:
2条回答
  • 2021-01-01 23:10

    The command object itself should implement the undo / redo functionality.

    The commands are generally pushed and popped from a stack maintained by a command manager to implement multi level undo. When commands are executed they are pushed onto the stack and when they are undone they are popped from the stack.

    The memento pattern would be used in conjunction with the command pattern, it is not a replacement to the usage of the command pattern. It would be used to maintain the state required for the undo operation.

    0 讨论(0)
  • 2021-01-01 23:10

    You might also want to consider the memento pattern for this, we use it and it works brilliant for undo.

    0 讨论(0)
提交回复
热议问题