Readers vs Constructors: Dependency Injection showdown
summary
Argues that dependency injection is just passing parameters and demonstrates it by building an in-memory key‑value store (ConcurrentHashMap + Futures), a food storage, a fridge/cooker and an IoT notifier, then refactors to show effect tracking by moving the key‑value dependency into a function and wrapping it as the Reader monad. Shows how constructor-based DI hides implementation details, how to combine both, and compares tooling like MacWire and Guice (mentions Play, Scaldi, SubCut). Recommends start with plain Scala wiring.
AI-written summary · about
chapters (16)
- 0:00Introduction
- 0:58Dependency Injection
- 3:33What you dont need
- 4:30Who is Adam
- 5:20KeyValue Store
- 6:41Food Storage
- 8:23Add Food
- 18:30Class Parameters
- 23:30Compile Time Error
- 23:53Create IOT dependency
- 26:33Change method signature
- 32:03Reader monad
- 35:41Remove function
- 41:11Tracking effects
- 43:01Combining the two
- 44:11Summary
related talks
54mDependency Injection revisited
40mFundamentals of Dependency Injection
46mSlaying Sacred Cows: Deconstructing Dependency Injection
30mThe Imposter’s Guide To Dependency Injection
32mLet's Build a Dependency Injection Framework
01h 29mDependency Injection in C++ - A Practical Guide
55mFrom dependency injection to dependency rejection
37mAdvanced multi-platform dependency injection
