kveratis (3) [Avatar] Offline
While reading the first chapter around the section (pg 44) where it talks about using an event log to show how we arrived at a given state something occurred to me.
I've read a lot about CQRS and the book on unified log programming which make extensive use of event logs to enable re-creating the present or prior states from
the event log. However, how do you handle the issue of the domain and/or business logic changing at some point in the middle of the event log. Where if you were
to re-run the events through the updated logic, different results would have occurred for past events meaning that you could not arrive at exactly the same state.
Given the fact the businesses rarely retain the same logic for a given business process for very long, this would seem to be a common problem. Should the log just
follow changing of attribute values (i.e. balance changes, and address changes) or should it be bound the particular business event that may encapsulate other changes?
Debasish Ghosh (116) [Avatar] Offline
Re: Questions on Event Logs
As you have correctly mentioned this is an important aspect that needs to be handled when u r doing event based modeling a la CQRS. The most common approach towards handling this issue is to use some serialization technique that can handle backwards compatibility of domain objects. As an example you can use JSON as the serialization format and implement serialization in such a way that backward compatibility is maintained. e.g. when u introduce a new field in your domain object treat it as an Option / Maybe type in serialization so that if you don't have that field in older journals of the log, then also serialization doesn't break. Have a look at this SoF thread and the links there in for some more pointers .. http://stackoverflow.com/questions/9169584/how-to-retrieve-historical-events-after-changes-to-domain-event-structure