Async injection
summary
Shows how to stop async leaking into the domain by treating C# async as a monad and injecting behavior into the Task<T> monad instead of changing domain signatures. Uses concrete C# tools: Task<T>, Lazy<T>, LINQ select/selectMany, a custom Maybe<T> and controller/repository examples. Refactors a restaurant reservation flow: move ReadReservations/Create to the boundary, keep MaitreD logic synchronous, return Maybe/Task wrappers, and compose with Select/Match. Result is deterministic domain logic, async where needed, and no leaked async in interfaces.
AI-written summary · about
chapters (27)
- 0:00Intro
- 0:24Outline
- 2:49Domain Model
- 13:16Zen Buddhism
- 14:19The XY problem
- 16:07Monads
- 17:57Structures
- 21:38Functors
- 22:14Lazy computation
- 27:07Collections
- 28:57Tasks
- 31:17Semi containers
- 31:47Novel of T
- 38:01Composable helper functions
- 39:16Example application
- 47:47impure operations
- 50:13leaky abstraction
- 50:57post method
- 53:19code changes
- 55:11reservation
- 56:08match
- 56:21compiler warning
- 56:48post method change
- 57:12get better
- 57:30pure function
- 58:59removing IMHOD
- 59:09wrapping up
related talks
59mGet value out of your monad
01h 01mCorrecting Common Async/Await Mistakes in .NET 9
55mAsync internals in .NET
57mAsync programming in .NET: Best practices
01h 00mCorrecting Common Async/Await Mistakes in .NET
49mCorrecting Common Mistakes in Asynchronous .NET Code
56mCorrecting Common Async/Await Mistakes in .NET 8
01h 05mCorrecting Common Async/Await Mistakes in .NET 10
