Objective Views : Chapter 12 Commands : Using or Not Using Command Objects
Using or Not Using Command Objects
Commands are ideal for performing actions initiated by the end-user. When you manipulate the canvas programmatically, you can avoid contending with the overhead of creating command objects and then recording them in the transaction model for undo/redo.
Commands are the ideal approach for performing common actions. If you want to use commands without logging them in the transaction model, turn off logging in the model before you execute the command.
If you want to avoid using commands completely, call the methods in the model directly. Remember that even though a command recalls what action it is performing, it always calls methods in the model to complete the action. Find the appropriate method for what you want to do in the model. The viewport displaying your canvas does not update automatically when you use commands. To update the viewport programmatically, call CODModel::UpdateComponents() to notify all of the model’s observers that a portion of the screen needs updating.