Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
20250624 関数型DDD 13
Search
saka
December 24, 2025
17
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
20250624 関数型DDD 13
saka
December 24, 2025
More Decks by saka
See All by saka
20250304 関数型DDD 6
sakatttttta
0
25
20241219 Github Actionsの面倒いところ
sakatttttta
0
18
20250109 関数型
sakatttttta
0
11
20250116 関数型DDD 2
sakatttttta
0
11
20250123 関数型DDD 3
sakatttttta
0
11
20250206 関数型DDD 4
sakatttttta
0
12
20250213 関数型DDD 4
sakatttttta
0
12
20250220 Hono カスタムfetch
sakatttttta
0
10
20250225 関数型DDD 5
sakatttttta
0
9
Featured
See All Featured
Navigating Team Friction
lara
192
16k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.2k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.9k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
68
59k
Code Review Best Practice
trishagee
74
20k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
For a Future-Friendly Web
brad_frost
184
10k
Raft: Consensus for Rubyists
vanstee
142
7.8k
WENDY [Excerpt]
tessaabrams
14
40k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
800
The SEO identity crisis: Don't let AI make you average
varn
0
590
Java REST API Framework Comparison - PWX 2021
mraible
34
9.8k
Transcript
DDD
ResultͷϦετ
ݱࡏͷϦετ
None
Γํʢskipʣ
None
reduceRightޙΖ͔Βॲཧ
ඇಉظ
ResultͱҰॹ
AsyncResultΛ࡞ͬͯ͋͛Δ type CheckAddressExists = UnvalidatedAddress -> AsyncResult<CheckedAddress, AddressValidationError>
γϦΞϥΠζ
None
Result let workflowWithSerialization jsonString = jsonString |> deserializeInputDto // JSON͔ΒDTO
|> inputDtoToDomain // DTO͔ΒυϝΠϯΦϒδΣΫτ |> workflow // υϝΠϯͷίΞϫʔΫϑϩʔ |> outputDtoFromDomain // υϝΠϯΦϒδΣΫτ͔ΒDTO |> serializeOutputDto // DTO͔ΒJSON // ࠷ऴग़ྗผͷJsonString
λϓϧ
/// ରԠ͢ΔDTOܕ type SuitDto = Heart = 1 | Spade
= 2 | Diamond = 3 | Club = 4 type RankDto = Ace = 1 | Two = 2 | Queen = 12 | King = 13 type CardDto = { Suit : SuitDto Rank : RankDto_attachment }
બܕ
type Example = | A | B of int |
C of string list | D of Name type ExampleDto = { Tag : string // "A", "B", "C", "D" ͷ͍ͣΕ͔1ͭ // έʔεAσʔλແ͠ BData : Nullable<int> // έʔεBͷσʔλ CData : string[] // έʔεCͷσʔλ DData : NameDto // έʔεDͷσʔλ }
ӬଓԽ
ʹ͍Ζ͏
Ͳ͏ͬͯʁ
// υϝΠϯϩδοΫͱI/O͕ࠞࡏ͢ΔϫʔΫϑϩʔ let payInvoice invoiceId payment = // DB͔ΒಡΈࠐΉ let
invoice = loadInvoiceFromDatabase(invoiceId) // ࢧ͍Λద༻͢Δ invoice.ApplyPayment(payment) // ҟͳΔ݁ՌΛॲཧ͢Δ if invoice.IsFullyPaid then markAsFullyPaidInDb(invoiceId) postInvoicePaidEvent(invoiceId) else markAsPartiallyPaidInDb(invoiceId)
// ڥք͚ͮΒΕͨίϯςΩετͷʹ͋ΔίϚϯυϋϯυϥʔ let payInvoice payInvoiceCommand = // DB͔ΒಡΈࠐΉ let invoiceId
= payInvoiceCommand.InvoiceId let unpaidInvoice = loadInvoiceFromDatabase invoiceId // I/O // ७ਮͳυϝΠϯͰͷݺͼग़͠ let payment = payInvoiceCommand.Payment // ७ਮ let paymentResult = applyPayment unpaidInvoice payment // ७ਮ // ݁ՌΛॲཧ match paymentResult with | FullyPaid -> markAsFullyPaidInDb invoiceId // I/O postInvoicePaidEvent invoiceId // I/O | PartiallyPaid updatedInvoice -> updateInvoiceInDb updatedInvoice // I/O
1,2ͱ͔Ҿ͖ͯΔ