8

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).

jaco0646
  • 15,303
  • 7
  • 59
  • 83
George Mauer
  • 117,483
  • 131
  • 382
  • 612

3 Answers3

7

You could look for the memento pattern

Melursus
  • 10,328
  • 19
  • 69
  • 103
2

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
  • 110,348
  • 25
  • 193
  • 263
1

I suggest you have a look at Martin Fowler's temporal patterns: http://www.martinfowler.com/eaaDev/timeNarrative.html

charlb
  • 1,076
  • 9
  • 18