Slide 1

Slide 1 text

Domain Driven Design Microxchg Michael Plöd

Slide 2

Slide 2 text

Origins > Books by Eric Evans and Vaughn Vernon > More relevant than ever in the advent of microservices > Implicit dependencies are getting explicit > Various advancements: > Domain Events > Event Sourcing / CQRS > Event Storming

Slide 3

Slide 3 text

Motivation > Strict separation between IT and business > Waterfall model did not deliver desired results > Strong divergences in > Architecture > Business Rules > Organisation

Slide 4

Slide 4 text

Key aspects > Don’t mistake DDD as a plain collection of (design) patterns > DDD is rather a collection of attitudes, organizational aspects and some patterns > DDD focusses on a very agile approach > DDD has impact on development, software-architecture, enterprise- architecture, team organization and project management

Slide 5

Slide 5 text

Core-learnings > The Domain is the heart of the system > Concepts of the domain will be reflected in the (software) design > Engineering over technology > Attitude over strict plans > Culture over a fixed collection of principles > Continuous learning > Ubiquitous language

Slide 6

Slide 6 text

Parts of DDD Strategic Design (Internal) 
 Building Blocks Large Scale
 Structure Destillation

Slide 7

Slide 7 text

Strategic Design consists of Bounded Context Context Map Shared Kernel Customer / 
 Supplier Conformist Anticorruption
 Layer Separate Ways Open / Host 
 Service Published 
 Language Strategic Design

Slide 8

Slide 8 text

Bounded Context Every sophisticated business domain consists of a bunch 
 of Bounded Contexts Each Bounded Context contains models and maybe other contexts The Bounded Context is also a boundary for the meaning of a given model

Slide 9

Slide 9 text

Example Reservations Event
 Management Badges Customer Name Payment Details Adress Company Session Registrations Lunch Preferences Name Job Description Twitter Handle

Slide 10

Slide 10 text

Example > Each Bounded Context has its own model of a customer > This is a major enabler for independent microservices > Name might be a use case for shared data but does not have to be

Slide 11

Slide 11 text

Context Map - 1 The Bounded Context by itself does not deliver an overview of the system By introducing a Context Map we describe the contact between models / contexts The Context Map is also a great starting point for future transformations

Slide 12

Slide 12 text

Context Map - 2 The Context Mapping Patterns are no Best Practices, they describe a current state Context Mapping usually adresses existing landscapes You can identify interesting hotspots in existing landscapes

Slide 13

Slide 13 text

Context Map Patterns Shared Kernel Customer / Supplier Conformist Anticorruption Layer Separate Ways Open / Host Service Published Language Two teams share a subset of the domain model including code and maybe the database. The shared kernel is often refered to as the core domain.

Slide 14

Slide 14 text

Context Map Patterns Shared Kernel Customer / Supplier Conformist Anticorruption Layer Separate Ways Open / Host Service Published Language There is a customer / supplier relation ship between two teams. The downstream team is considered to be the customer, sometimes with veto rights.

Slide 15

Slide 15 text

Context Map Patterns Shared Kernel Customer / Supplier Conformist Anticorruption Layer Separate Ways Open / Host Service Published Language The downstream team conforms to the model of the upstream team. There is no translation of models and no vetoing. If the upstream model is a mess, it propagates to the downstream model.

Slide 16

Slide 16 text

Context Map Patterns Shared Kernel Customer / Supplier Conformist Anticorruption Layer Separate Ways Open / Host Service Published Language The anticorruption layer is a layer that isolates a client’s model from another system’s model by translation.

Slide 17

Slide 17 text

Context Map Patterns Shared Kernel Customer / Supplier Conformist Anticorruption Layer Separate Ways Open / Host Service Published Language There is no connection between the bounded contexts of a system. This allows teams to find their own solutions in their domain.

Slide 18

Slide 18 text

Context Map Patterns Shared Kernel Customer / Supplier Conformist Anticorruption Layer Separate Ways Open Host Service Published Language Each Bounded Context offers a defined set of services that expose functionality for other systems. Any downstream system can then implement their own integration. This is especially useful for integration requirements with many other systems.

Slide 19

Slide 19 text

Context Map Patterns Shared Kernel Customer / Supplier Conformist Anticorruption Layer Separate Ways Open Host Service Published Language Published Language is quite similar to Open Host Service. However it goes as far as to model a Domain as a common language between bounded contexts.

Slide 20

Slide 20 text

Draw a Context Map https://github.com/mploed/ddd-strategic-design-spring-boot

Slide 21

Slide 21 text

Context Map Example Shop Online
 Ads Warehouse Logistics Payment U D D D D U U U C
 F O
 H
 S C U
 S O
 H
 S O H S A C L S K S K

Slide 22

Slide 22 text

Usual Architecture Patterns > Event-Driven Architecture > REST > SOA > Microservices / Self-Contained Systems > CQRS > Reactive / Actor Model

Slide 23

Slide 23 text

Domain Events > Bounded Contexts can issue Domain Events > Domain Events are important occurrences in an Domain > UserVerified > ShoppingCartCheckedOut > ShipmentDelivered > Domain Events are usually based on eventual consistency > Major driver for high degree of decoupling between Bounded Contexts

Slide 24

Slide 24 text

Domain Events Customer
 Notification
 Bounded Context Shipping
 Bounded
 Context Shipment
 Delivered
 Event Messaging
 System Shipment
 Delivered
 Event

Slide 25

Slide 25 text

An event is something 
 that happened in the past t now Event Event Event Event Event

Slide 26

Slide 26 text

The names of the events are part of the
 Ubiquitous Language D D D

Slide 27

Slide 27 text

ShipmentDeliveredEvent
 CustomerVerifiedEvent CartCheckedOutEvent CreateCustomerEvent
 WillSaveItemEvent
 DoStuffEvent

Slide 28

Slide 28 text

Scope your events based on
 Aggregates D D D

Slide 29

Slide 29 text

An Event is always immutable !