How to Use Dependency Injection to Write Maintainable Software
summary
Shows concrete C++ patterns and tradeoffs for dependency injection: pass read‑only data as const refs, prefer value or span for sequences, inject behaviors with std::function or concepts for static polymorphism, and use factories to defer instantiation. Covers lifetime choices: std::shared_ptr vs unique/refs, aliasing constructor, Folly Observer for mutable shared data, and testing with Google Mock. Demonstrates wiring options and a holder/factory pattern that composes components without leaking implementation details.
AI-written summary · about
chapters (8)
- 0:00Introduction
- 1:34Understanding dependency injection
- 5:39Passing dependencies
- 8:50Data dependencies
- 21:12Behavioral dependencies
- 30:07Wiring components
- 43:36Factories and lifecycle
- 52:56Abstraction and conclusion
related talks
01h 07mDependency Injection Patterns: Efficiency and Usability
03mLightning Talk: Dependency Injection for Modern C++
56mLaw of Demeter: A Practical Guide to Loose Coupling
01h 03mRetiring the Singleton Pattern
57mThe 7 Deadly Sins of Dependency Injection
58mGetting a grip on your code dependencies
01h 19mDependency Injection: Theory and Practice
51mDesign Patterns: Facts and Misconceptions
