Coding Dojo: Event Sourcing NerdDinner

We had a great Coding Dojo last tuesday! We welcomed 18 people in total, many of them enthusiastic community members. The dojo was a great success: we had a lot of fun, learned new stuff, met new people and had a great discussion afterwards.

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)
All event handling is done synchronously, so you don’t have to bother with eventual consistency and all that stuff. Instead, you can just focus on the core event sourcing concepts. Also, the result is actually a hybrid mutable state / ES solution, since there’s still some data stored in table rows. We didn’t feel it was worth the effort to completely move to event sourcing for this dojo, though it might be a fun exercise. You can have a look at the code on GitHub. Please note that this infrastructure is not production-ready nor production-tested, so keep that in mind if you want to base your own infrastructure on this code.

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)

Gezocht: ondernemende nerds!

› Wil jij je hersens bij ons laten kraken?

Wil je iets waarmaken met Infi?

Wil jij een eigen webapplicatie of mobiele app waarmee jij het bij anderen maakt?

Waargemaakt door de nerds van Infi.
Nerds met liefde voor softwareontwikkeling en die kunnen communiceren. En heel belangrijk: wat we doen, doen we met veel lol!

Wij willen het fixen. Laat jij van je horen?

Voor wie heb je een vraag?