知识卡片
备忘录由状态拥有者恢复
备忘录模式让发起者在变化前生成快照,保管者保存并在需要时把快照交回,具体恢复仍由发起者完成。这样撤销不要求外界理解内部状态,保留封装。快照可能占用大量内存,也需防止保管者擅改内部内容;它实现的是受控状态恢复,不是所有外部动作的反演。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
- · 第13章 易用性
原书出处 · 1 处
- 易用性 · 查看原书依据
In this way, the caretaker knows nothing about how state is managed; the memento is simply an abstraction that the caretaker employs. Benefits: • The obvious benefit of this pattern is that you delegate the complicated process of implementing undo, and figuring out what state to preserve, to the class that is actually creating and managing that state.
参考来源
- 位置:《Software Architecture in Practice, 4th Edition》第13章《易用性》(来源项目:book-sources;源文件:extracted/Software Architecture in Practice, 4th Edition/_epub-src/ch13.html)
- 结论依据:所引连续原文给出本卡机制或取舍;条件与示例结合本节已读上下文解释。
- 原始内容:In this way, the caretaker knows nothing about how state is managed; the memento is simply an abstraction that the caretaker employs. Benefits: • The obvious benefit of this pattern is that you delegate the complicated process of implementing undo, and figuring out what state to preserve, to the class that is actually creating and managing that state.