Slide 1

Slide 1 text

© 2014 SpringOne 2GX. All rights reserved. Do not distribute without permission. DOMAIN-DRIVEN DESIGN / OLIVERGIERKE ƻ [email protected] FUNDAMENTAL FOR MICROSERVICES

Slide 2

Slide 2 text

2

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

4 http://www.infoq.com/minibooks/domain-driven-design-quickly

Slide 5

Slide 5 text

Microservices ♥
 Domain-Driven Design 5 11:10 — Beethoven Saal

Slide 6

Slide 6 text

6

Slide 7

Slide 7 text

6

Slide 8

Slide 8 text

Implementing Domain-Driven Design 7

Slide 9

Slide 9 text

Value objects 8

Slide 10

Slide 10 text

Stringly typed code 9 public class Customer { private Long id; private String firstname, lastname, email; … }

Slide 11

Slide 11 text

Stringly typed code 10 public class SomeService { public void createUser(String firstname,
 String lastname, String email) { … } }

Slide 12

Slide 12 text

11 public class Customer { private Long id; private Firstname firstname; private Lastname lastname; private EmailAddress emailAddress; … }

Slide 13

Slide 13 text

Value Objects are a
 PITA to build in
 some languages. 12

Slide 14

Slide 14 text

Still, they’re worth it. 13 See „Power Use of Value Objects in DDD“ by Dan Bergh Johnsson.

Slide 15

Slide 15 text

Lombok — putting the spice back into Java. 14

Slide 16

Slide 16 text

15 @Value public class Customer { UUID id = UUID.randomUUID(); Firstname firstname; Lastname lastname; EmailAddress email; @Value static class EmailAddress { String value; } }

Slide 17

Slide 17 text

AutoValue 16 Project website on GitHub.

Slide 18

Slide 18 text

Entities & Aggregates 17

Slide 19

Slide 19 text

18 Order LineItem Product Invoice Customer Payment Address Email

Slide 20

Slide 20 text

18 Order LineItem Product Invoice Customer Payment Address Email

Slide 21

Slide 21 text

Persistence technology
 VS.
 Domain model 19

Slide 22

Slide 22 text

Aggregate =
 Entity + Repository 20

Slide 23

Slide 23 text

21 Order LineItem Product Invoice Customer Payment Address Email

Slide 24

Slide 24 text

Bounded Context 22

Slide 25

Slide 25 text

Order LineItem Product Invoice Customer Payment Address

Slide 26

Slide 26 text

24 Shipping Accounting Catalog Orders User
 Registration

Slide 27

Slide 27 text

24 Shipping Accounting Catalog Orders User
 Registration Accounting Payment information Billing Address Shipping Shipping address Customer Product

Slide 28

Slide 28 text

Domain-Driven Design & Monoliths 25

Slide 29

Slide 29 text

Avoid technologies that get in your way. 26

Slide 30

Slide 30 text

How to enforce
 context boundaries? 27

Slide 31

Slide 31 text

What about
 consistency? 28

Slide 32

Slide 32 text

References between Bounded Contexts? 29

Slide 33

Slide 33 text

Domain Events 30

Slide 34

Slide 34 text

31 Level 0: No events at all

Slide 35

Slide 35 text

31 Level 0: No events at all Level 1: Explicit operations

Slide 36

Slide 36 text

If you’re calling two setters in a row, you’re missing a concept. 32

Slide 37

Slide 37 text

33 Level 0: No events at all Level 1: Explicit operations Level 2: Some operations as events

Slide 38

Slide 38 text

State transitions
 become domain
 events. 34

Slide 39

Slide 39 text

35 Level 0: No events at all Level 1: Explicit operations Level 2: Some operations as events Level 3: Event Sourcing

Slide 40

Slide 40 text

Domain-Driven Design & Microservices 36

Slide 41

Slide 41 text

Bounded contexts 
 define system
 boundaries. 37

Slide 42

Slide 42 text

38 Shipping Accounting Catalog Orders User
 Registration Accounting Payment information Billing Address Shipping Shipping address Customer Product

Slide 43

Slide 43 text

39 Shipping Accounting Catalog Orders User
 Registration Accounting Shipping

Slide 44

Slide 44 text

40 Shipping Accounting Catalog Orders User
 Registration Accounting Shipping HTTP Messaging

Slide 45

Slide 45 text

Architecture is less
 likely to deteriorate
 as it’s harder to
 violate boundaries. 41

Slide 46

Slide 46 text

Restructuring
 service boundaries
 is much harder. 42

Slide 47

Slide 47 text

Inter-Service communication
 becomes remote
 communication. 43

Slide 48

Slide 48 text

Accept and embrace eventual consistency between services. 44

Slide 49

Slide 49 text

Domain Events 45

Slide 50

Slide 50 text

REST & Messaging 46

Slide 51

Slide 51 text

Domain events
 become state
 transitions. 47

Slide 52

Slide 52 text

Hypermedia for state transition and explicit events. 48

Slide 53

Slide 53 text

Thanks! 49