Re: Action based undo or snapshot based undo?
Re: Action based undo or snapshot based undo?
- Subject: Re: Action based undo or snapshot based undo?
- From: Izidor Jerebic <email@hidden>
- Date: Thu, 30 Jan 2003 14:20:24 +0100
On Thursday, Jan 30, 2003, at 13:54 Europe/Ljubljana, Izidor Jerebic
wrote:
Could you give an example of this difficulty?
I posit that any action which should be undoable results in one or
more
attribute changes in the state of your model objects. If something is
destructive and non-reversible it is because you are not adding an
undo
action when you should, or parts of your application 'state' are not
captured by the state of the model objects, which means you haven't
designed your model correctly.
Hi, Greg!
I am just thinking about introducing Undo into large application, and
have come to some conclusions that are rather different than yours.
Namely, my classes are not simply "structs with set/get methods". They
contain quite a lot of internal state that is not accessible to
outside world (as objects should be). And when I need to reverse an
effect of a method, say "optimize", that means I need to restore some
of the internal state of the object (and maybe other objects, too).
Since there is no public interface to do this, I would need to invent
a method specially for this purpose. And for every such case there
needs to be another method. It seems much easier to me to record a
snapshot of an object (since my model knows how to archive/unarchive),
than to invent new methods each time I change something in the model
classes. I only need to add some simple processing (reconnecting to
external world after undo, if necessary).
The solution with archiving/unarchiving and little extra processing
for undo seems to me quite appealing - it is rather general and
elegant, and can be implemented with little extra code (there are
hundreds of classes in my model).
Any thoughts on this, maybe a catch I did not notice?
izidor
Sorry for replying to my own post, but I was not clear - my idea was to
archive the changed objects only, not the whole model. So only the
changed objects get archived and restored (with special processing for
insert/delete)...
izidor
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.