[Biodevelopers] undo-redo code

Malay Kumar Basu curiouser at ccmb.res.in
Wed Jan 15 11:29:39 EST 2003


Dear Dipu:

There are several ways this can be done. It depends on the language you
are using. 

In object-oriented language this can done using a pattern called
"Memento". Read any design pattern book to get the idea how it is
basically done.

In brief you need an internal reprentation of the object, in Java this can
done using serialization. Maintain a stack of the object internal state,
and pop it whenever the "undo" action is required. "Redo" should "push"
the object onto the stack. 

Remember, undo and redo costs a lot. You can mix "flyweight" pattern with
it. An unlimited "undo/redo" will involve writing a serialized object onto
virtual ram.

All the best

Malay






More information about the Biodevelopers mailing list