Eventmodeling: Describing Business Rules with Given/When/Then
How to make business rules visual, understandable, and testable
October 2023 • 8 min read • Event Modeling
In the last episode of the “Eventmodeling & Eventsourcing” Podcast, we mainly discussed “Given / When / Then” scenarios to describe business policies and touched on slice-based architectures, especially how they simplify concurrent development and version control.
Why Different Types of “Given / When / Then”?
We use business rules in three places:
- When we change the system
- When we query the system
- When we perform automated background tasks
1. Rules to Change the System
To change the system, we use state change slices – typically consisting of:
- a screen
- a command (blue)
- and resulting event(s) (orange)
📌 Example: A customer clicks Submit Order on the orders page → this stores an event in the system.
These rules are described using Given / When / Then:
- Given – sets system into a defined state
- When – describes the action
- Then – describes the expected outcome
This approach makes rules:
- Visual
- Understandable
- Testable (e.g., Gherkin syntax)
Example
When the
Submit Ordercommand is executed → ExpectOrder Submittedevent stored with same ID
Preventing duplicates:
Given:
Order Submittedalready exists When: trying to submit again → Then: error state is expected
2. Rules for Read Models and Automations
In the podcast, Adam and I explained our different takes:
My approach:
- Provide Given / Then for automations
- Optional When for context
- Emphasis: describe state & expected outcome
Given:
Order SubmittedThen:Customer Notifiedis triggered automatically
Adam’s approach:
- Treat automations like state change slices
- Use full Given / When / Then
e.g. Treat automated SNS notification like a human-triggered command
Why “Given / When / Then” Matters
They are:
- Often ignored at the start
- Crucial for explaining how your system works
- A natural way to bridge business and technical understanding
What Else You Should Know
- 🎓 Want hands-on learning? Join workshops on Event Modeling
- 📘 “Understanding Eventsourcing” provides deep insights into these concepts
- 🧩 Great workflow between Figma & Miro for Eventmodeling
🎧 Follow the Eventmodeling & Eventsourcing Podcast 👋 See you next week!
Ready to Learn More?
My book “Understanding Eventsourcing” gives you the blueprint. But reading alone will take your team too long.
I can teach your team how to build these blueprints faster and skip the whole trial-and-error phase. Let’s have a chat about how this applies to your project.
Still 2 Team-Spots left for the Event Modeling Workshop this month.
Want to learn how to apply Event Modeling and Event Sourcing in practice?
Follow the Online Course “Implementing Eventsourcing” - comes with a Lifetime Event Modeling Toolkit License.