41
DDD & Microservices At last, some boundaries! Eric Evans @ericevans0 domainlanguage.com Complex business logic Domain-driven Design Domain modeling Ubiquitous language

DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

DDD & MicroservicesAt last, some boundaries!

Eric Evans @ericevans0

domainlanguage.com

Complex business logic

Domain-driven Design Domain modeling

Ubiquitous language

Page 2: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

You say ‘bandwagon’ like it’s a bad thing!

Adrian Cockcroft

Page 3: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

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.

• But! Different people mean different things.

Page 4: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

Services and Messages

Sm mm m mm

Page 5: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

Am

m

m m

m mB

Page 6: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

Aa

b

a a

b bB

How do they understand the messages?

Page 7: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

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.

Page 8: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

Aa

b

a a

b bB

partnersA B

Context Map translator

bounded contexts

Page 9: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

partnersA B

Context Map

Aa

b

a a

b bB

C

a

a

a

Page 10: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

Asymmetrical Relationships

Context Name Context Namerelationship

(point toward power)

Page 11: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

Context Map

Aa

b

a a

b bB

C

a

a

a

partnersA B

C

Page 12: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

Context Map

Aa

b

a a

b bB

C

a

a

a

partnersA B

C

conforms

Page 13: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

Context Map

partnersA B

C

conforms

Aa

b

a a

b bB

C

a

a

a

D

aa

a

Page 14: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

Context Map

Aa

b

a a

b bB

C

a

a

a

D

aa

a

partnersA B

C

conforms

D

AC

Page 15: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

Context Map

partnersA B

C

conforms

D

AC

Aa

b

a a

b bB

C

a

a

a

D

aa

a

E a a

Page 16: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

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

Page 17: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

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

Page 18: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

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

Page 19: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

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

Page 20: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

There are always multiple models.

enterprise model shared database schema

unified field theory one ring

Page 21: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

Models need to be clear, not big.

• Useful models need crisp definitions.

• Definitions require clear context.

• Useful models need simple assertions.

• Assertions require boundaries.

Page 22: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

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

Page 23: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

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

Page 24: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

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

Page 25: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

Context Map

Aa

b

a a

b bB

C

a

a

a

D

aa

a

E a a

F

bb

a

a

a

f

partners

A B

C

conforms

D

AC

E conforms

Fconforms

AC

BBoMBBoM

Page 26: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

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.

Page 27: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

Context Map

Aa

b

a a

b bB

C

a

a

a

D

aa

a

E ae ae

F

bb

ae

ae

ae

f

What can be done?

partners

A B

C

conforms

D

AC

E

Fconforms

AC

BBoMBBoM

BBoM

Page 28: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

Not all of a large system will be well designed.

Page 29: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

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

???

???

Mitigation

Page 30: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

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

Page 31: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

Microservice as Context Boundary

• Allow high-concept modeling in a messy world.

• Allow specialized models for distinct problems.

• Mitigate consequences of design mistakes.

• Acknowledge the rough and tumble of enterprises.

• But…

• Very interesting stuff is not inside the services!

Page 32: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

Interchange context

Page 33: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

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

Page 34: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

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

Page 35: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

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

Page 36: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

`• A relatively generic data model for sharing.

• or…

• A place to model protocols of interaction.

• Modeling and design of higher-level solutions.

• A domain language tuned to these purposes.

Page 37: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

Interchange Context• Expressed in terms of service interfaces/messages.

• Distinct from the objects/functions of the internals of a service.

• Prevents distortion/freezing of early-dominant contexts.

• Gives big-picture understanding when we have many services.

• Usually more than one! (Avoid enterprise model.)

Page 38: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

Why not logical boundaries?

• Smart people I respect 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.

Page 39: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

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

boundaries. Microservices have them.

• Proliferation of services recreate some of the old problems.

• Context Maps help visualize and communicate about those problems.

• Modest use of interchange contexts can help produce coherent sets of microservices.

Page 40: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

Not all of a large system will be well designed.

Page 41: DDD & Microservices - QCon London 2020€¦ · Wrap up • Subtle design (such as DDD) requires concrete boundaries. Microservices have them. • Proliferation of services recreate

DDD & MicroservicesAt last, some boundaries!

Eric Evans @ericevans0

domainlanguage.com