From: brett l. <wak...@gm...> - 2006-07-17 06:31:19
|
I've been thinking about how to approach implementing Undo/Redo. It seems to me that there are two basic strategies that we can attempt. In each of them, we need to create a stack to store actions. Then, we can place the stack in front of or after the code to execute the action. The basic flow would look something like this: Stack before Action (Stack as EventHandler): 1. Stack object receives call from UI to take an action. 2. Stack stores action taken 3. Stack object calls model object to resolve action. Stack after Action (Stack as a Listener): 1. Model code receives call to act. 2. Model resolves action 3. Model notifies Stack object of action just taken. I haven't really done much of an analysis of which approach would be more work or have additional implications. There also could be other approaches I haven't thought of, as well. What are your thoughts on this? Is there a solution with an obvious advantage? ----Brett. |