Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object...

46
Unleash Your Domain Greg Young

Transcript of Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object...

Page 1: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object

Unleash Your Domain

Greg Young

Page 2: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object

Agenda

• The Issues

• The Breakthroughs

– Explicit State Representation

– Event Storage

– Command Query Separation

– Asynchronous Context Mapping

• Summary

• Questions

Page 3: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object
Page 4: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object
Page 5: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object
Page 6: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object
Page 7: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object
Page 8: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object

State transitions are an important part of our problem space and should be modeled within

our domain.

Page 9: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object
Page 10: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object

Purchase Order

Line Items (n)

Shipping Information

Page 11: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object

Cart Created

3 Items Added

Shipping Information

Added

Page 12: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object

Purchase Order

AddItemCommand

ChangeAddressCommand

AddItemCommand AddItemCommand

Page 13: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object
Page 14: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object

Cart Created

3 Items Added

1Item Removed

Shipping Information

Added

Page 15: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object
Page 16: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object

6

5

4

3

2

1

7

Page 17: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object

5

snap

4

3

2

1

6

Page 18: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object
Page 19: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object
Page 20: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object

Application Services

Data Storage

Domain Object

Client

Remote Facade

Request DTO DTO returned

Send up DTO Status returned

Domain Object

Page 21: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object

DTO Sent Ack/Nak Response

Request DTO DTO returned

Send DTO Back to Server

Show DTO on Screen

User Interacts With DTO

Page 22: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object

Map DTO from Domain

Edit DTO in UI

Send DTO to Server

Map Data from DTO to Domain

Save Domain Object(s)

Page 23: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object

Query Data

Build Commands

Send Commands to Domain

Domain Validates Commands

Save Domain Object(s)

Page 24: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object

Data Storage

Application Services

Domain Object

Remote Facade

Domain Object

Client

Message Sent Ack/Nak Response

Thin Read Layer (Direct to DTO)

Remote Facade

Request DTO DTO returned

Page 25: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object

Data Storage

Application Services

Domain Object

Remote Facade

Domain Object

Client

Message Sent Ack/Nak Response

Thin Read Layer (Direct to DTO)

Remote Facade

Request DTO DTO returned

Write (Command) Read (Query)

Page 26: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object

A single model cannot be appropriate for reporting, searching, and transactional

behaviors…

Page 27: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object
Page 28: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object
Page 29: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object

The model that a client needs the data in a distributed system is screen based and different

than the domain model.

Page 30: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object
Page 31: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object

Most queries can operate with relaxed consistency…

Page 32: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object

Data Storage

Application Services

Domain Object

Remote Facade

Domain Object

Thin Read Layer (Direct to DTO)

Remote Facade

Data Storage

Client

Denormalizer -------------------

Anti Corruption

Page 33: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object
Page 34: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object

Getters and Setters are a domain anti-pattern.

Page 35: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object
Page 36: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object
Page 37: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object
Page 38: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object

Most Bounded Contexts can interact with relaxed consistency.

Page 39: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object
Page 40: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object

Using relaxed consistency allows us to increase our scalability and availability!

Page 41: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object

“Man acts as though he were the shaper and master of language, while in fact it is language that is the master of man.”

Page 42: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object

State transitions are an important part of our problem space and should be modeled within

our domain.

Page 43: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object

Getters and Setters are a domain smell.

Page 44: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object

Most Bounded Contexts can interact with relaxed consistency.

Page 45: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object

A single model cannot be appropriate for reporting, searching, and transactional

behaviors…

Page 46: Unleash Your Domain - Jfokus · snap 4 3 2 1 6 . Application Services Data Storage Domain Object Client Remote Facade Request DTO DTO returned Send up DTO Status returned Domain Object

Questions