Memento design pattern and State design pattern

后端 未结 3 1902
小蘑菇
小蘑菇 2021-01-05 14:29

Memento design pattern is used for restoring objects to previous state, like undo. But we can do undo and redo multiple times. I have read articles multiple times but still

3条回答
  •  孤街浪徒
    2021-01-05 15:24

    The "state" in the "state pattern" is not the same kind of state that a memento pattern enables. A better name for the state pattern would be the "mode pattern". See this description of it for more details.

    Now, one might use a memento to describe the state of an object that has a mode pattern involved, but that is the only particular relationship they have.

提交回复
热议问题