Domain-Driven Design: The tutorial

Preview:

Citation preview

Not all of a large system will be well designed.

Strategic Design

Partnered in Scandinavia with

Eric Evans

Making Models Work in Large Projects

Eric EvansDomain Language, Inc.

Not all of a large system will be well designed.

Ground Up Rebuild

Ground Up Rebuild

Ground Up Rebuild

Ground Up Rebuild

Year 1

Year 2

Year 3

Legacy Replaced

Exciting New Features

Let’s Refactor

Let’s Refactor

domain A sphere of knowledge, influence, or activity.

Define Domain

domain A sphere of knowledge, influence, or activity.

The subject area to which the user applies a program is the domain of the software.

Define Domain

Why bother with models?

The critical complexity of most software projects is in understanding the domain itself.

Critical Complexity Is

What is a model?

origindestinationcustoms clearance (opt)

Route Specification

Itinerary

{ordered}

*

0..1

{Itinerary must satisfy specification}

Routing Servicea Route Specification

an Itinerary satisfyingthe RouteSpecification

Cargo

vessel Voyage IDload dateload locationunload dateunload location

Leg

Chinese Map

Mercator Map

model A system of abstractions that describes selected aspects of a domain and can be used to solve problems related to that domain.

Define Model

model A system of abstractions that describes selected aspects of a domain and can be used to solve problems related to that domain.

Define Model

model A system of abstractions that describes selected aspects of a domain and can be used to solve problems related to that domain.

Define Model

A Model Serves a Particular Use.

A Model Serves a Particular Use.

• Not “as realistic as possible”

A Model Serves a Particular Use.

• Not “as realistic as possible”

• Useful relative to specific set of domain scenarios

ubiquitous languageA language structured around the domain model and used by all team members to connect all the activities of the team with the software.

Define Ubiquitous Language

context The setting in which a word or statement appears that determines its meaning.

Define Context

There are always multiple models.

Rowing 8

“Context Map”

communications commitment/capability of team(s)

cont

rol o

f all

asso

ciat

ed s

yste

ms

SEPARATE WAYS

ANTI-CORRUPTIONLAYER

Single BOUNDEDCONTEXT

CUSTOMER/SUPPLIER TEAMS

SHARED KERNEL

CONFORMIST

OPEN HOSTSERVICE

communications commitment/capability of team(s)

cont

rol o

f all

asso

ciat

ed s

yste

ms

SEPARATE WAYS

ANTI-CORRUPTIONLAYER

Single BOUNDEDCONTEXT

CUSTOMER/SUPPLIER TEAMS

SHARED KERNEL

CONFORMIST

OPEN HOSTSERVICE

cooperative upstream/downstream

communications commitment/capability of team(s)

cont

rol o

f all

asso

ciat

ed s

yste

ms

SEPARATE WAYS

ANTI-CORRUPTIONLAYER

Single BOUNDEDCONTEXT

CUSTOMER/SUPPLIER TEAMS

SHARED KERNEL

CONFORMIST

OPEN HOSTSERVICE

uncooperative upstream/downstream

Custom House Currency Exchange System

early 2006

Custom House Context Map

SPOT

TBS

Custom House Context Map

SPOT

TBS

D

U

Custom House Context Map

SPOT

TBS

D

U

Custom House “SPOT” Modelof Currency Exchange Deal

Object Interpretation of Implicit “TBS” Model

Explicit Translation

Custom House Currency Exchange System

late 2006

Map What Is

Push Translation to the Borders

Single, Unified Model within Any One Context

Single, Unified Model within Any One Context

(Where careful design is going on.)

Single, Unified Model within Any One Context

No duplication...

Single, Unified Model within Any One Context

No duplication...within a context!

Duplication between...

Single, Unified Model within Any One Context

No duplication...within a context!

Duplication between...AOK!

Ground Up Rebuild

Let’s Refactor

The Enterprise Model

One Ring to rule them all, One Ring to find them, One Ring to

bring them all, and in the darkness bind them

Not all of a large system will be well designed.

Distilling the Core Domain

Distilling the Core Domain

Generic Subdomains

Distilling the Core Domain

Generic Subdomains

Supporting Subdomains

Distilling the Core Domain

Generic Subdomains

Supporting Subdomains

Core Domain

Distilling the Core Domain

– What makes your system worth writing?

Distilling the Core Domain

– What makes your system worth writing?

– Why not buy it off the shelf?

Distilling the Core Domain

– What makes your system worth writing?

– Why not buy it off the shelf?

– Why not outsource it?

Distilling the Core Domain

– What makes your system worth writing?

– Why not buy it off the shelf?

– Why not outsource it?

Effort Distribution

Effort Distribution

Effort Distribution

Effort Distribution

Ground Up Rebuild

Year 1

Year 2

Year 3

Legacy Replaced

Exciting New Features

Which Part is Core?

Which Part is Core?

Responsibility Traps

…Or, Why do irresponsible programmers become heroes?

Let’s Hack

Let’s Hack

Which Parts are Core?

Which Parts are Core?

Responsibility Traps

• Building a platform to make other (lesser) programmers more productive.

• Cleaning up other people’s mess.

What’s a responsible designer to do?!!

How could we just build the core part?

Build Platform Based on Model

Build Platform Based on Model

Strategy

• Draw a Context Map.• Work with business leadership to define

Core Domain.• Design a platform that supports work in

the Core Domain.• Work with management to give freedom to

the Core Domain Platform Context.• Develop and model in the Core Domain.

Strategy

• Keep an eye on your Context Map.• Keep working with business leadership as

Core Domain narrows and shifts.• Guard your platform that supports work in the

Core Domain.• Keep working with management to maintain

freedom of the Core Domain Platform Context.• Keep developing and evolving the model in the

Core Domain.

Strategic DDD Resources

www.domaindrivendesign.org

Domain-Driven Design by Eric Evans

PART 4!

www.domainlanguage.com

Recommended