What is the difference between IEditableObject and IRevertibleChangeTracking?

前提是你 提交于 2019-11-30 02:03:20

The two interfaces are not mutually exclusive. They are simply intended to support different yet somewhat related scenarios, which might as well be implemented by the same given class. Here's a quick explanation:

IEditableObject Interface

The IEditableObject interface is designed to support the scenario where an object needs to manage its internal state in some particular way while it is being edited.

For that reason the interface includes methods that explicitly mark when the editing phase is started, completed or aborted, so that the appropriate actions can be taken to modify the object's state at those stages.


IRevertibleChangeTracking interface

The IRevertibleChangeTracking interface is designed to support the scenario where an object needs to be able to rollback to its previous state.

The interface has methods that mark when the object's current state should be made permanent or it should be reverted to the last known permanent state.

IEditableObject is used for short term, revertanble modifications such as dialog boxes.

IRevertibleChangeTracking is used for long-term, revertible changes such as editing a record and tracking whether or not the record needs to be saved.

I often implement both interfaces so that I have the ability to support two levels of undo.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!