Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Fundamental Domain-Driven Design For Microservices
Search
Oliver Drotbohm
April 19, 2016
Programming
11
1k
Fundamental Domain-Driven Design For Microservices
Slides of the talk I gave at JAX 2016, Mayence.
@springcentral
Oliver Drotbohm
April 19, 2016
Tweet
Share
More Decks by Oliver Drotbohm
See All by Oliver Drotbohm
It Takes Two to Tango – Designing Module Interactions in Modulithic Spring Applications
olivergierke
4
480
Bottom-Up Architecture – Bridging the Achitecture Code Gap
olivergierke
4
800
Spring Modulith – A Deep Dive
olivergierke
7
3.9k
Spring for the Architecturally Curious Developer
olivergierke
5
1.7k
Spring Boot 3 & Spring Framework 6
olivergierke
4
1.9k
Architecturally-evident Java Applications with jMolecules
olivergierke
8
2.7k
A Deep Dive into Spring Application Events
olivergierke
12
3.1k
Building Better Monoliths – Modulithic Applications with Spring Boot
olivergierke
4
880
Spring HATEOAS – Hypermedia APIs with Spring
olivergierke
1
660
Other Decks in Programming
See All in Programming
各クラウドサービスにおける.NETの対応と見解
ymd65536
0
190
数十万行のプロジェクトを Scala 2から3に完全移行した
xuwei_k
0
360
ブラウザ単体でmp4書き出すまで - muddy-web - 2024-12
yue4u
3
500
良いユニットテストを書こう
mototakatsu
10
3.2k
競技プログラミングへのお誘い@阪大BOOSTセミナー
kotamanegi
0
360
コンテナをたくさん詰め込んだシステムとランタイムの変化
makihiro
1
150
責務を分離するための例外設計 - PHPカンファレンス 2024
kajitack
8
2k
testcontainers のススメ
sgash708
1
130
DevFest - Serverless 101 with Google Cloud Functions
tunmise
0
130
テストコードのガイドライン 〜作成から運用まで〜
riku929hr
5
1k
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
760
Mermaid x AST x 生成AI = コードとドキュメントの完全同期への道
shibuyamizuho
1
290
Featured
See All Featured
Designing Experiences People Love
moore
138
23k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
Docker and Python
trallard
42
3.2k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
29
920
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.4k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
Building Better People: How to give real-time feedback that sticks.
wjessup
366
19k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
2k
Building Applications with DynamoDB
mza
91
6.1k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
Transcript
© 2014 SpringOne 2GX. All rights reserved. Do not distribute
without permission. DOMAIN-DRIVEN DESIGN / OLIVERGIERKE ƻ
[email protected]
GRUNDLEGENDES FÜR MICROSERVICES
2
None
4 http://www.infoq.com/minibooks/domain-driven-design-quickly
Microservices ♥ Domain-Driven Design 5 Slides and video by Michael
Plöd.
6
6
Implementing Domain-Driven Design 7
Value objects 8
Stringly typed code 9 public class Customer { private Long
id; private String firstname, lastname, email; … }
Stringly typed code 10 public class SomeService { public void
createUser(String firstname, String lastname, String email) { … } }
11 public class Customer { private Long id; private Firstname
firstname; private Lastname lastname; private EmailAddress emailAddress; … }
Value Objects are a PITA to build in some languages.
12
Still, they’re worth it. 13 See „Power Use of Value
Objects in DDD“ by Dan Bergh Johnsson.
Lombok — putting the spice back into Java. 14
15 @Value public class Customer { UUID id = UUID.randomUUID();
Firstname firstname; Lastname lastname; EmailAddress email; @Value static class EmailAddress { String value; } }
AutoValue 16 Project website on GitHub.
Key opponents: Mapping libraries that need to (de)serialize them. 17
Entities & Aggregates 18
Persistence technology VS. Domain model 19
Challenges with JPA: Value objects as @Entity Flat relationships
20
21 Order LineItem Product Invoice Customer Payment Address Email
21 Order LineItem Product Invoice Customer Payment Address Email
Repositories turn an entity into an aggregate root. 22
23 Order LineItem Product Invoice Customer Payment Address Email
Bounded Context 24
Order LineItem Product Invoice Customer Payment Address
26 Shipping Accounting Catalog Orders User Registration
26 Shipping Accounting Catalog Orders User Registration Accounting Payment information
Billing Address Shipping Shipping address Customer
26 Shipping Accounting Catalog Orders User Registration Accounting Payment information
Billing Address Shipping Shipping address Customer Product
Domain-Driven Design & Monoliths 27
Avoid technologies that get in your way. 28
How to enforce context boundaries? 29
What about consistency? 30
References between Bounded Contexts? 31
Domain Events 32
33 Level 0: No events at all
33 Level 0: No events at all Level 1: Explicit
operations
If you’re calling two setters in a row, you’re missing
a concept. 34
35 Level 0: No events at all Level 1: Explicit
operations
35 Level 0: No events at all Level 1: Explicit
operations Level 2: Some operations as events
State transitions become domain events. 36
37 Level 0: No events at all Level 1: Explicit
operations Level 2: Some operations as events
37 Level 0: No events at all Level 1: Explicit
operations Level 2: Some operations as events Level 3: Event Sourcing
Domain-Driven Design & Microservices 38
Bounded contexts define system boundaries. 39
40 Shipping Accounting Catalog Orders User Registration Accounting Payment information
Billing Address Shipping Shipping address Customer Product
41 Shipping Accounting Catalog Orders User Registration Accounting Shipping
42 Shipping Accounting Catalog Orders User Registration Accounting Shipping HTTP
Messaging
Architecture is less likely to deteriorate as it’s harder to
violate boundaries. 43
Restructuring service boundaries is much harder. 44
Inter-Service communication becomes remote communication. 45
Accept and embrace eventual consistency between services. 46
Domain Events 47
REST & Messaging 48
Domain events become state transitions. 49
Hypermedia for state transition and explicit events. 50
Thanks! 51