Using Immutable Data Structures
summary
Argues that making data immutable in C# reduces runtime errors and removes many cross-thread synchronization needs, showing practical tools and tradeoffs: uses System.Collections.Immutable to demonstrate that "mutating" an immutable list returns a new instance, shows record types and AutoMapper/Newtonsoft.Json mapping via constructors for immutable DTOs, and diagrams a real refactor where an added setter broke an interface contract. Recommends the builder/factory pattern for configurable services and notes EF Core can hydrate immutable entities but only with significant boilerplate, so weigh cost versus benefit.
AI-written summary · about
chapters (19)
- 0:00Introduction
- 4:27Fsharp
- 7:59Bad immutability jokes
- 9:52Understanding the state of your application
- 12:29Example
- 14:14Synchronization Quadrant
- 16:02Moores Law
- 17:17Multithreaded Computing
- 18:17History of Immutability
- 22:02Anonymous Types
- 24:25Unnecessary Setters
- 27:35Why Setters
- 30:08AntiPatterns
- 32:56System Collections
- 35:00AutoMapper
- 37:08Builder Pattern
- 41:14Entity Framework
- 46:50Summary
- 51:38Redux
related talks
41mThe Surprising Effectiveness of Immutable Data Structures
52mImmaculate Code (pure code)
01h 06mC# 8: Be Good, Get Good or Give Up
59mBringing C# nullability into existing code - dammit is not the answer!
31mLet's get Functional (en)
01h 12mLegacy Refactoring
53mMaintainable JavaScript with Functional Patterns
30mRefactoring and Test Fakes: Crafting Resilient Code with Confidence
