views:

216

answers:

2

What are some design patterns for keeping a history of an object as it changes. I don't need anything as heavy duty as event sourcing, just the ability to save past versions when a specific event happens (in this case when a print form button is pressed).

+6  A: 

You could look for the memento pattern

Melursus
Thanks, I forgot all about that one!
George Mauer
Less is more. Very nice indeed.
JMD
+2  A: 

This sounds isomorphic to tracking undo information. The usual pattern for this is a variant of the Command pattern: you keep a queue in time order of previous states, with an operation to restore to the previous state.

Charlie Martin
I was going to write an answer to this question, but you covered every point I wanted to make.
Jekke
The difference is that the history itself is persisted whereas with undo info you don't need anything of the sort.
George Mauer