Women in Technology

Hear us Roar

  Form Your Own Design Pattern Study Group
Subject:   solution for undo() method in MacroCommand
Date:   2009-06-07 19:48:37
From:   mkrk
This is with refrence to the solution provided for undo() method in the MacroCommand. The solution provided was :
for (int i = 0; i < commands.length; i++ ) {

I believe this solution is wrong. When the undo is called it should undo the last command first
then go all the way to 1st command. It should be

for (int i = commands.length - 1; i >= 0; i-- ) {

Is my solution correct or am i missing something.

I would appreciate your response.