I have a project for my university where I'm using PowerDesigner
to model an application that should be an abstract MS Visio
, basically a generic graph editor.
I'm supposed to implement the command pattern, but focusing only on the actual work space (and not, say, the hierarchy tree). Now, I have an abstract class that has an abstract function called execute()
and an empty (but not abstract) function named undo()
. The idea is to have the concrete commands override the first method, but only have the undoable commands override the second method.
I'm having some trouble in understanding what qualifies as a command. The undoable methods are somewhat easy to name, as I have Move
, Resize
, Rotate
, AlterProperty
, Delete
and Add
. The commands that aren't undoable are the problem.
Is every action on the toolbar a command? I was thinking of putting Zoom
and Scroll
as a command, but I'm not sure if that even makes sesne. As for Cut
, Copy
and Paste
, the first is pretty much a filling of the Clipboard
element list, after which the Delete
command is called, while the latter two are pretty much adding and removing from the Clipboard
list, so I don't know if I should classify that as a command.
Basically, the question is - what do I do with commands that aren't undoable? Should every action create a command object?