Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are some design patterns for doing version control of an object?

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

like image 977
George Mauer Avatar asked Feb 24 '09 20:02

George Mauer


3 Answers

You could look for the memento pattern

like image 54
Melursus Avatar answered Oct 18 '22 17:10

Melursus


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.

like image 38
Charlie Martin Avatar answered Oct 18 '22 19:10

Charlie Martin


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

like image 1
charlb Avatar answered Oct 18 '22 18:10

charlb