ddd & microservices - goto...

37
DDD & Microservices At last, some boundaries! Eric Evans @ericevans0 domainlanguage.com

Upload: others

Post on 03-Jun-2020

23 views

Category:

Documents


0 download

TRANSCRIPT

DDD & MicroservicesAt last, some boundaries!

Eric Evans @ericevans0

domainlanguage.com

Why do I like microservices?

• Autonomous teams with isolated implementation.

• Acknowledge the rough and tumble of enterprises.

• Cattle not pets.

• A philosophical break from the past — gives us a chance to shake assumptions.

Possibly, some other people mean something else:

What I’m saying may not apply to that!

Services and Messages

Sm mm m mm

Am

m

m m

m mB

Aa

b

a a

b bB

How do they understand the messages?

Bounded Context

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

• bounded context The conditions under which a particular model is defined and applicable.

Aa

b

a a

b bB

partnersA B

Context Map

partnersA B

Context Map

Aa

b

a a

b bB

C

a

a

a

Asymmetrical Relationships

Context Name Context Namerelationship

(point toward power)

Context Map

Aa

b

a a

b bB

C

a

a

a

partnersA B

C

Context Map

Aa

b

a a

b bB

C

a

a

a

partnersA B

C

conforms

Context Map

partnersA B

C

conforms

Aa

b

a a

b bB

C

a

a

a

D

aa

a

Context Map

Aa

b

a a

b bB

C

a

a

a

D

aa

a

partnersA B

C

conforms

D

AC

Context Map

partnersA B

C

conforms

D

AC

Aa

b

a a

b bB

C

a

a

a

D

aa

a

E a a

Context Map

Aa

b

a a

b bB

C

a

a

a

D

aa

a

E a a

partnersA B

C

conforms

D

AC

E conforms

Context Map

partnersA B

C

conforms

D

AC

E conforms

Aa

b

a a

b bB

C

a

a

a

D

aa

a

E a aa

a

a

Context Map

partnersA B

C

conforms

D

AC

E conforms

Aa

b

a a

b bB

C

a

a

a

D

aa

a

E a a

F

bb

a

a

a

f

Context Map

Aa

b

a a

b bB

C

a

a

a

D

aa

a

E a a

F

bb

a

a

a

f

partnersA B

C

conforms

D

AC

E conforms

Fconforms

AC

Models need to be clear, not big.

• Useful models need crisp definitions.

• Definitions require clear context.

• Useful models need simple assertions.

• Assertions require boundaries.

There are always multiple models.

Context Map

Aa

b

a a

b bB

C

a

a

a

D

aa

a

E a a

F

bb

a

a

a

f

partnersA B

C

conforms

D

AC

E conforms

Fconforms

AC

Context Map

partnersA B

C

conforms

D

AC

E conforms

Fconforms

AC

Aa

b

a a

b bB

C

a

a

a

D

aa

a

E a a

F

bb

a

a

a

f

Context Map

Aa

b

a a

b bB

C

a

a

a

D

aa

a

E a a

F

bb

a

a

a

f

partnersA B

C

conforms

D

AC

E conforms

Fconforms

AC

BBoM

Context Map

partnersA B

C

conforms

D

AC

E conforms

Fconforms

AC

BBoMBBoM

Aa

b

a a

b bB

C

a

a

a

D

aa

a

E a a

F

bb

a

a

a

f

Context Map

partnersA B

C

conforms

D

AC

E conforms

Fconforms

AC

BBoMBBoM

Aa

b

a a

b bB

C

a

a

a

D

aa

a

E ae ae

F

bb

ae

ae

ae

f

Fiction! Map what is.

Not all of a large system will be well designed.

Context Map

Aa

b

a a

b bB

C

a

a

a

D

aa

a

E ae ae

F

bb

ae

ae

ae

f

partnersA B

C

conforms

D

AC

E

Fconforms

AC

BBoMBBoM

BBoM

???

???

Patterns describe good places to be.

Context Map

Aa

b

a a

b bB

C

a

a

a

D

aa

a

E ae ae

F

bb

ae

ae

ae

f

partnersA B

C

conforms

D

AC

E

Fconforms

AC

BBoMBBoM

AC

ACBBoM

Interchange context

Context Map

Aa

b

a a

b bB

C

a

a

a

D

aa

a

E a a

F

bb

a

a

a

f

partnersA B

C

conforms

D

AC

E conforms

Fconforms

AC

Context Map

partnersA B

C

conforms

D

AC

E conforms

Fconforms

AC

Aa

b

a a

b bB

C

i

i

i

D

ii

i

E i i

F

bb

i

i

i

f

Context Map

Aa

b

a a

b bB

C

i

i

i

D

ii

i

E i i

F

bb

i

i

i

f

partnersI

B

C

conforms

D

AC

E conforms

Fconforms

AC

AAC

Why not logical boundaries?

• Smart people point out that most of what I want is the logical partitioning of the system.

• We’ve had decades to get that to work.

• Some techniques are too subtle to survive the rough and tumble.

Wrap up• Subtle design (such as DDD) requires concrete

boundaries.

• Lots of services recreate some of the old problems.

• Context Maps help visualize and communicate about those problems.

• Modest use of interchange contexts is one way of organizing coherent services.

Not all of a large system will be well designed.

DDD & MicroservicesAt last, some boundaries!

Eric Evans @ericevans0

domainlanguage.com