In my application, I want to provide the user with a small undo functionality. The user does not have many actions that can be undone by the user. In particular, the actions:
- Adding notes to an object
- Object color
- Flag objcet with string
Now I was thinking about how to implement this. At first I thought of the Action class, which is an abstract base class for three different actions that can be taken by the user. Each time the user takes these actions, a new corresponding instance of the subclass of this abstract class Action is created and inserted into the list containing all the actions.
Whenever the user wants to cancel something, the list is displayed to the user, and he can choose which action he wants to cancel.
Now I thought what should be stored in such an action object:
- object state before action
- the actual action that was performed (for example, a line added to the notes of the object)
I'm not sure if this is enough. I also thought of something like a chronological ordering, but this is necessary since the list can be kept chronologically correct.
Are there any other things I should consider?
anon
source share