DDD Europe 2022 - Program

Discovering Aggregate Implementation Patterns and Event-Sourcing via "Code Koans"


Anton Stöckl and Dagmar de Haan

Anton StöcklDagmar de Haan

(This is a hands-on lab with limited capacity)

There are many ways to implement the Aggregate pattern from Domain-Driven Design:

  • OOP style or functional style
  • Traditional or event-sourced
  • Internal state, external state, on-the-fly state (reconstituted inside the aggregate)
  • Reconstitute the full state or just the minimal state needed to make decisions
  • Recording changes or returning changes

Many variations are possible, especially with event-sourced aggregates. I recently played with a functional, event-sourced, minimal, on-the-fly state combination which is a good fit for a prototype phase and this is one of or variations in the workshop. The different use-cases don't share any code, so the Aggregate is reduced to a concept.

We will discover as many of those variations as possible during the workshop, but we will focus on the event-sourced variations, which are much more interesting for our simple example.

Attendees will implement different versions of the same Aggregate in a "Code Koans" like fashion. For each variation, there will be test cases and a skeleton that has to be filled with the missing code to make the tests green. Some variations will have "bonus challenges" where test cases will have to be extended first.

What you will discover:

  • different styles of implementing an Aggregate
  • how you can implement a conceptual Aggregate without having a big "object"
  • the basics of event-sourcing
  • a light version of ensemble (mob) programming
  • the idea of "Code Koans"
Hands-on prerequisites

We will supply Git repositories containing Java and Kotlin code. Attendees need a laptop with an IDE that is suitable for Java/Kotlin and should have JUnit installed. https://github.com/MaibornWolff/aggregate-implementation-patterns-java https://github.com/klimisa/aggregate-implementation-patterns-csharp https://github.com/MaibornWolff/aggregate-implementation-patterns-kotlin

About Anton Stöckl

Senior IT Architect @ MaibornWolffTwitter

Anton Stöckl works for MaibornWolff GmbH in Munich as a Senior IT Architect since 2019.

He brings along more than 2 decades of experience in professional software development with roles as developer, software architect, and team lead.

He is especially interested in Domain-driven Design and how to build solid and loosely coupled Microservice architectures.

Another important aspect for him is "socio-technical architecture" - a holistic approach to align IT architectures and autonomous agile development teams.

He loves to coach or mentor development teams, run workshops, and to write blog posts.

Some other important paradigms, architectural styles, and modeling methods he likes to apply:

  • Hexagonal Architecture (aka. Ports & Adapters)
  • Event-Sourcing and CQRS
  • Distributed, event-driven systems
  • Event Storming
  • Trunk-based development

Lately, he is working with Golang using a functional style of programming as much as possible and applicable.

About Dagmar de Haan

IT Architect @ MaibornWolff

Dagmar de Haan worked as an IT architect at MaibornWolff in Frankfurt from 2014 to 2022. She has been working as a freelance software developer and IT architect since mid-2022. Since her beginnings in software development a good 20 years ago, she has been concerned with the question of what makes good software, how it is created and above all how it is preserved. Her main interests include

  • Agile software development
  • Design pattern
  • Clean code
  • Software reengineering
  • TDD
  • Voice control with Alexa