Undo
- Definition
- Store the actions of a user as objects in a list, and allow actions to be undone
Many applications allow a user to "undo" their actions. After the user has made some changes and realizes that they are on the wrong track, they may want to reverse one or more actions and take a different approach. This can be facilitated by the application by keeping track of all actions in a stack. Each action needs to know how to perform itself, and to reverse its effects.
A variation is undo/redo where a user can go up and down the action stack. Actions on the stack are not removed on undo, but the action pointer is just moved back one action. A redo will move the action pointer forward.
Actions may be extended. Rather than treating each typed letter as a single action, update the "edit" each time a new letter is typed. This way the edit can be undone in a single step.
Examples
- Text processing, image editing
When should you use it?
- When a user is allowed to correct edits