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

5

Slide 6

Slide 6 text

Implementing Domain-Driven Design 6

Slide 7

Slide 7 text

Value objects 7

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

Lombok — putting the spice back into Java. 13

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

Entities & Aggregates 16

Slide 16

Slide 16 text

17 Order LineItem Product Invoice Customer Payment Address Email

Slide 17

Slide 17 text

17 Order LineItem Product Invoice Customer Payment Address Email

Slide 18

Slide 18 text

Persistence technology
 VS.
 Domain model 18

Slide 19

Slide 19 text

Aggregate =
 Entity + Repository 19

Slide 20

Slide 20 text

20 Order LineItem Product Invoice Customer Payment Address Email

Slide 21

Slide 21 text

Bounded Context 21

Slide 22

Slide 22 text

Order LineItem Product Invoice Customer Payment Address

Slide 23

Slide 23 text

23 Shipping Accounting Catalog Orders User
 Registration

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

Domain-Driven Design & Monoliths 24

Slide 26

Slide 26 text

Avoid technologies that get in your way. 25

Slide 27

Slide 27 text

How to enforce
 context boundaries? 26

Slide 28

Slide 28 text

What about
 consistency? 27

Slide 29

Slide 29 text

References between Bounded Contexts? 28

Slide 30

Slide 30 text

Domain Events 29

Slide 31

Slide 31 text

30 Level 0: No events at all

Slide 32

Slide 32 text

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

Slide 33

Slide 33 text

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

Slide 34

Slide 34 text

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

Slide 35

Slide 35 text

State transitions
 become domain
 events. 33

Slide 36

Slide 36 text

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

Slide 37

Slide 37 text

Domain-Driven Design & Microservices 35

Slide 38

Slide 38 text

Bounded contexts 
 define system
 boundaries. 36

Slide 39

Slide 39 text

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

Slide 40

Slide 40 text

38 Shipping Accounting Catalog Orders User
 Registration Accounting Shipping

Slide 41

Slide 41 text

39 Shipping Accounting Catalog Orders User
 Registration Accounting Shipping HTTP Messaging

Slide 42

Slide 42 text

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

Slide 43

Slide 43 text

Restructuring
 service boundaries
 is much harder. 41

Slide 44

Slide 44 text

Inter-Context communication
 becomes remote
 communication. 42

Slide 45

Slide 45 text

Accept and embrace eventual consistency between services. 43

Slide 46

Slide 46 text

Domain Events 44

Slide 47

Slide 47 text

REST & Messaging 45

Slide 48

Slide 48 text

Domain events
 become state
 transitions. 46

Slide 49

Slide 49 text

Hypermedia for state transition and explicit events. 47

Slide 50

Slide 50 text

Thanks! 48