mardi 13 décembre 2016

Command design pattern for unrelated commands

All the examples and tutorials I found online so far deal with commands that either add or subtract or some other operation on a value - Calculator is the common example.

However What if you have commands that don't behave like those in a calculator? Like moving an object on the screen to an x, and y position. Or adding and removing an object. These commands are unrelated, so keeping track of a current x, y position, has no meaning if the next command in the stack is a create object command that you need to undo.

Any suggestions how to handle this?

Aucun commentaire:

Enregistrer un commentaire