Book Club 10/2023: Functional Patterns in C#
Happy spooky season!
This month I've focused on functional domain modeling and related patterns. We're just a few weeks away from the release of the next version of C#, and like each previous version it'll introduce even more functional features. We still aren't getting discriminated unions, but as C# becomes more functional, these patterns are becoming increasingly more attractive. Traditionally, C# is written in OO or procedural styles, and from my perspective there doesn't seem to be a great deal of discussion among C# engineers about incorporating functional patterns. Maybe you run in different circles, but I think there's room for improvement across the board here. Even the result monad, which can be used within an entirely OO context, is infrequently implemented.
I think it's important to be discussing functional patterns in C#, for a few practical reasons:
- Eventually we're getting DU, and that's going to change a lot of things
- Our F# colleagues are doing great work in this area, we should engage them more
- Using functional patterns is cool
But above all, if C# supports these patterns and they can help us write better code, why would we neglect them? To explore this topic, I've curated a set of talks by Scott Wlaschin and Mark Seemann who both do a great job explaining functional programming from a conceptual perspective, demonstrating its power in F#, and ultimately demonstrating C# equivalents.
I hope these talks make you all as excited for discriminated unions in C# as I am!
- Domain Modeling Made Functional - Scott Wlaschin (2019)
- Functional Design Patterns - Scott Wlaschin (2017)
- The Power of Composition - Scott Wlaschin (2018)
- The Lazy Programmer's Guide to Writing Thousands of Tests - Scott Wlaschin (2020)
- Functional Architecture - The Pits of Success - Mark Seemann (2016)
- Get Value out of Your Monad - Mark Seemann (2018)
- From Dependency Injection to Dependency Rejection - Mark Seemann (2017)
- Dependency Injection Revisited - Mark Seemann (2018)