Event Sourcing NerdDinner
For this dojo we prepared a custom version of NerdDinner, the canonical ASP.NET MVC example app, so it could act as a playground for experimenting with event sourcing. To support event sourcing we made these modifications:
- Added basic infrastructure for raising events (the Event, Event, IEventData and EventScope types)
- Load events when hydrating a Dinner entity (DinnerRepository.Find)
- Added DbSet to the NerdDinners DbContext to add a table for storing Events to disk
- Have a hook for the NerdDinners DbContext intercepting published Events (NerdDinners.OnEventsPublished)
- Removed mocking from the unit tests so that you could run the tests against the DB
- Implemented RSVPing using Event Sourcing (RSVPController.Register)
Do try this at home
With the above code available at the start of the dojo, we set up a couple of exercises for pairs to tackle during the evening. I think doing these exercises is a good introduction to event sourcing, and most of the people that attended the dojo agreed.
If you want to try out event sourcing at your company or just want to experiment with it yourself, doing this dojo might be a great way to start. Just clone the code and try doing the included exercises (all exercises have accompanying tests to get you started). Please let us know about your results!
Also, if you'd like to participate in our next Coding Dojo: you are more than welcome! Just join our Meetup-group and we'll be sure to invite you.
(This blog is a summary of a personal blogpost that I posted earlier on FreekPaans.nl)