An abstract implementation of a basic command. Each derived class
must implement {@link Command#execute} and {@link Command#redo},
must either implement {@link #undo} or implement {@link #canUndo} to return false,and
must either override {@link #prepare} (this is the preferred approach) or can override {@link #canExecute} directly.
It is very convenient to use prepare, as it is guaranteed to be called only once just before canExecute is to be tested. It can be implemented to create any additional commands that need to be executed, and the result it yields becomes the permanent cached return value for canExecute.