Design Patterns – Logging Events for Reporting Purposes

design-patternslanguage-agnosticloggingreporting

Are there any design patterns or best practices around logging events for use in reporting and BI systems.

For example in a system which manages orders from a website, it would be beneficial if a customer support worker could type in an order number and see that it the order was placed on a certain day, dispatched on a certain day and delivered on another.

I can see 2 ways around this. I have an order object which has the fields:

OrderDate
DespatchDate
DeliveryDate

and populate them if they have happend otherwise they will be null

OR

log some sort of events like which are messages like:

Order Number - "12312312" - Ordered on '2014/01/01'
Order Number - "12312312" - Despatched on '2014/01/01'

and add store the events in a database.

Are there any guidelines for this?
For example how does the work item history in TFS work?

TFS History

Best Answer

Robert made good points in his answer.

In addition, you might want to look at Audit Log as described by Martin Fowler here (and perhaps, more generally, Temporal Patterns). If you wanted to do more than just business activity monitoring / business reporting of these events, you might want to look at Event Sourcing. Fowler provides an introduction here.

You can use these terms to search for other opinions on the web.

Related Topic