Spec driven development with EVE: event modeling, vertical slices and event sourcing

I personally don’t have that problem, but I keep seeing people complain that their agents go off on a tangent when they want them to build something and they struggle with verifying big PRs.

All the apps I’ve built since February have event models that describe exactly how it is implemented in production.

I don’t read PRs because I have a build step that also generates an event model that I can review. I can go straight to testing the app in production and tweak features if something doesn’t feel right in terms of UX.

Markdown is just words, open for interpretation, whereas event models even specify with example values tests can be based on.

The example

Our office recently opened up a bastu, so I thought of modeling a booking app as an exercise.

1. The event model

The sauna event model in Event Book: three slices, Set capacity, Book a slot and Free slots tonight, each with its screen, command or view, event, and Given/When/Then scenarios.

Notice how the event model reads like a story: from left to right, you can easily understand what happens in the system. Here is an alternative view that people might also be more comfortable with, read top down.

The same model as an outline, read top down

2. The spec we hand over

The builder payload for Book a slot

I hand over the whole event model for the orchestrator to distribute slices to smaller models or even local models.

3. The tests

The Given/When/Then test for Book a slot

And since the data is event sourced, there is no transformation to a data layer, and we can just test the history and resulting event values as is.

4. The code

The Book a slot code

The code for one slice is very simple. It takes event history, applies the business rules according to the GWT and returns an event if the command is successful.

5. The model that comes back

The build book shows the link to the code if I want to dive into the actual implementation and their tests.

The bastu build book: each slice links to its code, each scenario to its test

Plan next to built: 7 of 7 scenarios in both, one field only in built

I actually welcome pleasant surprises like this. The plan wasn’t perfect, but because we defined it in the scenario, the feature was built anyway. Mature tools like eventmodelers.ai have a dependency checker that highlights immediately when a field is missing a source, but it gives me an idea now to add that feature to Event Book so we catch issues in plan mode.

Where to start

If you’re starting a new project, have a look at the EVE stack. Our roles have now evolved: we need to learn to communicate better with our agents and event modeling is the tool that enables this.

Check out the build book and the repo here!

Obviously with a production app you would persist the events in a central store on the server, but to keep the example simple, we are using local storage.

If you want to find out more about the EVE stack, follow Martin Dilger on LinkedIn or check out eventmodelers.ai.