Achieving Loose Coupling with Pure Dependency Injection
summary
Argues that Pure Dependency Injection plus a central Composition Root in the app target produces loose coupling; shows a SwiftUI iOS app split into feature Swift packages, uses initializer injection with protocol-based repositories, and wraps SwiftData behind a CoffeeShopsRepository. Composers are properties/functions that create object-graph subtrees with singleton, scope, and transient lifetimes. Builds four dev app targets that launch single features, keeps previews and unit tests working, and demonstrates swapping implementations (e.g., mock or Core Data) without breaking consumers.
AI-written summary · about
chapters (14)
- 0:00Introduction to DI
- 1:32App walkthrough
- 3:53Dependency injection basics
- 6:11Types of injection
- 8:21Understanding object graphs
- 10:18Modularization with packages
- 12:04The composition root pattern
- 14:16Implementing composers
- 18:34App target implementation
- 21:22Lifetimes and routing
- 24:30Previews and composition
- 28:23DI in unit testing
- 30:05Dev apps and conclusion
- 32:13Q&A session
related talks
17mAchieving Loose Coupling with Pure Dependency
43mSwiftUI and DI
58mA Practical Guide to Loose Coupling
37mAdvanced multi-platform dependency injection
26mDependency Management in Clojure
50mDesign Patterns for Loosely Coupled Applications
49mReaders vs Constructors: Dependency Injection showdown
40mFunctional iOS Architecture in the SwiftUI Era
