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

3

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

Flense answered 24/2, 2009 at 20:3 Comment(0)
W
7

You could look for the memento pattern

Waddington answered 24/2, 2009 at 20:5 Comment(0)
L
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.

Leekgreen answered 24/2, 2009 at 20:6 Comment(1)
The difference is that the history itself is persisted whereas with undo info you don't need anything of the sort.Flense
O
1

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

Orangery answered 2/9, 2013 at 14:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.