Domain-Driven Design and Event-Driven Microservices

Matt Stine 2-Day Workshop
Tue-Wed, Sept 17-18

New architectural paradigms like microservices and evolutionary architecture, as well as the challenges associated with managing data and transactional contexts in distributed systems, have generated a renewed interest in disciplined software design and modular decomposition strategies. We know that the secret to obtaining the benefits of these architectures is getting the boundaries right, both at the team and the component/service level, and then keeping them right as the software continues to evolve! A key reason for getting the boundaries right is that it allows us to create a unified and ubiquitous language within the bounded contexts those boundaries enclose, allowing the business and engineers to have productive and coherent conversations.

Fortunately, there is a mature, battle-tested approach to domain modeling and system decomposition that is a perfect compliment to these architectures: Domain-Driven Design (DDD). In this course, we’ll leverage an exemplar business domain, that of a pizza delivery store, to illustrate DDD-based decomposition strategies, data architecture patterns, and implementations.

What You'll Learn and How You Can Apply It

By the end of this two-day training course, attendees will understand:

  • Why DDD is an effective tool for designing evolutionary architectures.
  • The basic concepts of DDD (DDD 101).
  • The importance of the Ubiquitous Language.
  • How DDD can be effectively combined with multiple technical architectures.
  • How pain points can be used to drive the evolution from a modular monolith to microservices.
  • The tradeoffs that must be negotiated with each major evolutionary change to an architecture.

And they’ll be able to:

  • Leverage Event Storming to arrive at a candidate domain model.
  • Translate an Event Storm into User Stories.
  • Effectively apply DDD patterns such as Bounded Context, Aggregate, and Domain Event to design modules that can be evolved into event-driven microservices.
  • Effectively leverage Hexagonal Architecture to implement modules that can be evolved into event-driven microservices.
  • Apply stepwise refactorings to evolve from a modular monolith to component-based to service-based architectures.
  • Apply automated fitness functions to ensure that architectural qualities are maintained throughout the architecture’s evolution.


Day One

Class Introduction (10 minutes)
Intro to the Course
Intro to the Instructor
Class Logistics
Class Outline

Lecture: Why do we need DDD? (15 minutes)

Lecture: What is Ubiquitous Language and why is it so important? (15 minutes)

Open Q&A and Class Discussion: Why DDD / Ubiquitous Language (10 minutes)

Lecture: DDD 101 - Strategic Design: Bounded Contexts, Context Mapping, Subdomains (30 minutes)

Open Q&A and Class Discussion: Strategic Design (10 minutes)

Morning Break (30 minutes)

Lecture: DDD 101 - Tactical Design: Aggregates, Entities, Value Objects, Domain Events, Application Services, Domain Services (30 minutes)

Open Q&A and Class Discussion: Tactical Design (10 minutes)

Lecture: Overview of Event Storming (15 minutes)

Lecture: Introduction to the Pizza Shop domain (10 minutes)

Class Activity: Mob Event Storming the Pizza Shop Domain (15 minutes)

Open Q&A and Class Discussion: Event Storming and Pizza Shop Domain (10 minutes)

Lunch (1 hour)

Group Activity: Event Storming Kata (90 minutes)

Afternoon Break (30 minutes)

Lecture: Discuss how Event Storm concepts translate into DDD concepts, User Stories, and TDD code (30 minutes)

Lecture: DDD and Technical Architectures (45 minutes)

Open Q&A and Class Discussion: Day One AMA (15 minutes)

Day Two

Day One Recap (10 minutes)

Lecture: Intro to Evolutionary Architectures and Fitness Functions (30 minutes)

Lecture: The App Continuum (30 minutes)

Lecture: Overview of the Pizza Shop Coding Exercise Environment (10 minutes)

Open Q&A and Class Discussion: Evolutionary Architecture / App Continuum (10 minutes)

Morning Break (30 minutes)

Student Activity: Lab 1: TDD Aggregate Root - Create Kitchen Commands with Business Logic and Invariants (20 minutes)

Lecture: Lab 1 Solution (10 minutes)

Student Activity: Lab 2: TDD Aggregate Root - Create and Publish Kitchen Domain Events (20 minutes)

Lecture: Lab 2 Solution (10 minutes)

Student Activity: Lab 3: TDD Aggregate Repository - Create Kitchen Repositories and Add Domain Events (20 minutes)

Lecture: Lab 3 Solution (10 minutes)

Lunch (1 hour)

Student Activity: Lab 4: TDD Aggregate Repository - Rehydrate Kitchen Aggregates by Reference (20 minutes)

Lecture: Lab 4 Solution (10 minutes)

Student Activity: Lab 5: TDD Application Service - Expose Kitchen Business Interface and Implement Transactions (20 minutes)

Lecture:Lab 5 Solution (10 minutes)

Student Activity: Lab 6: TDD Policy - Subscribe to a Kitchen Domain Event from within an Aggregate and Create CQRS View (20 minutes)

Lecture: Lab 6 Solution (10 minutes)

Afternoon Break (30 minutes)

Student Activity: Lab 7: TDD Policy - Subscribe to a Kitchen Domain Event from an Adjacent Aggregate and Update State (20 minutes)

Lecture: Lab 7 Solution (10 minutes)

Student Activity: Lab 8: Evolutionary Refactoring - Move from Packages to Components, Externalize Persistence (20 minutes)

Lecture: Lab 8 Solution (10 minutes)

Student Activity: Lab 9: Evolutionary Refactoring - Move from Components to Microservices, Externalize Eventing (20 minutes)

Lecture: Lab 9 Solution (10 minutes)



Basic familiarity with Domain-Driven Design concepts can ease your understanding of the course material. I recommend reading "Domain-Driven Design Distilled" by Vaughn Vernon to get a quick, 101-level overview.

We will be leveraging multiple technical architecture concepts in this course. Vaughn Vernon provides a great overview of them in Chapter 4 of "Implementing Domain-Driven Design".

Understanding Test-Driven Development is key to programming exercises we’ll complete. "Test-Driven Development: By Example" is a classic treatment of these concepts. You may also find "Growing Object-Oriented Software, Guided by Tests" a nice contextual treatment of TDD, mock objects, and object-oriented design.

We will use the Java programming language, as well as testing libraries such as JUnit, Mockito, and AssertJ. You should be comfortable with Java programming and automated testing libraries. Familiarity with Git and GitHub will be required. If you need to brush up your Git(Hub) skills, this Complete Git and GitHub Masterclass can be helpful.

We will leverage Docker to run some services like databases and message queues. If you’re not familiar with Docker, this book can help you get started.

Similarly, are any materials or downloads required in advance of the course?

  • A GitHub account
  • Course Materials from GitHub (TBD)
  • Your computer should be set up with the following capabilities:
  • Java 8
  • Maven (recent)
  • Git
  • The IDE/editor you are most comfortable using (make sure you have the Lombok plugin installed! Instructions for Eclipse and IntelliJ are linked).
  • Docker (recent)
  • It would also be helpful to have a free Realtime Board account, or failing that, a presentation/diagramming tool you feel comfortable and productive using.