Undo implementation with CQRS+ES

560 views
Skip to first unread message

Thomas Vantroyen

unread,
Mar 25, 2013, 7:10:57 AM3/25/13
to ddd...@googlegroups.com
Hi,

I was thinking that the Commands could serve as a wonderful source for implementing a generic undo feature.

For instance, a "reverse commandhandler" could then build the previous version of an aggregate to see what the previous Name was to create a Rename event to reverse a previous Rename command.

On the other hand, using an undo-stack as most applications do, probably will us get into trouble, since nothing is ever really undone, it just adds more commands and events and it will be complex to track where we are on the undo stack, especially when supporting undo and redo mixing.

Maybe CQRS+ES enables other/better functionality to help the user undo/redo mistakes?

greetings

Thomas Vantroyen

unread,
Mar 25, 2013, 11:02:30 AM3/25/13
to ddd...@googlegroups.com
Any concerns, ideas that come to mind?  Or suggestions on a better approach?

João Bragança

unread,
Mar 25, 2013, 11:16:26 AM3/25/13
to ddd...@googlegroups.com
The problem is what happens if two users are working on the same aggregate at the same time? Can you undo someone else's changes?

Maybe you can put the domain in the client and run it in memory. Put the aggregate version with each command on a stack. When you undo, only load the aggregate up to that version. Once the user syncs up with the server they can't undo anymore.




On Mon, Mar 25, 2013 at 8:02 AM, Thomas Vantroyen <thomas.v...@gmail.com> wrote:
Any concerns, ideas that come to mind?  Or suggestions on a better approach?

--
You received this message because you are subscribed to the Google Groups "DDD/CQRS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dddcqrs+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Sebastian Good

unread,
Mar 25, 2013, 11:20:51 AM3/25/13
to ddd...@googlegroups.com
"Undo" at the user interface level is not always granular at the same level as your commands are. As a naive example, imagine each keystroke in a word processing program were a command. Most programs will undo "the last few seconds", or "a few sentences" when you hit Undo. This might be hundreds of commands, but no user really wants to undo every keystroke. I think that the modeling of do and undo happens at the user interface level and needs to be carefully considered in light of domain requirements. Can I "undo" a tax return? Perhaps in the first 5 minutes, where we assume I just made a mistake. But 1 month later? Like anything else in your workflow, "Undo" needs to be analyzed as an explicit task to be carried out in light of the domain, not as a thing the user can do because it's technically convenient.


Rinat Abdullin

unread,
Apr 3, 2013, 2:02:54 AM4/3/13
to ddd...@googlegroups.com
Undo can probably be applied to the local changes (in case of occasionally connected app with A+ES), however after the changes get pushed to the master event store - there is no simple going back (we would need to compensate commands).

Rinat Abdullin | Technology Leader at Lokad.com | Writer at Abdullin.com | Contacts
Reply all
Reply to author
Forward
0 new messages