Dependency Injection in C++ - A Practical Guide
summary
Compares concrete DI techniques applied to a large legacy ticker‑processing codebase and shows which actually work: link-time substitution is brittle and abandoned; interfaces, templates and std::function are used with Google Mock and C++20 concepts; null objects and small base functional classes reduce test scaffolding; extracting eight responsibilities into three layered components cuts injection points dramatically; lazy initialization is solved by a provider function passed with a default to preserve ABI; prefers constructor injection over setters and globals.
AI-written summary · about
chapters (18)
- 0:00Introduction to talk
- 3:30Dependency injection myths
- 7:46Ways to inject functionality
- 11:43Inheritance and virtual functions
- 16:40Template-based injection
- 21:58Type eraser and function objects
- 24:45Null-valued objects for testing
- 26:13Setter and method injection
- 30:13Constructor injection
- 32:21Conceptual dependency injection
- 33:44Applied dependency injection
- 48:50Roadblocks in legacy code
- 51:21Refactoring for dependency injection
- 1:02:16Encapsulated functions
- 1:05:48Lazy object initialization
- 1:14:23Unexpected snags in legacy code
- 1:19:44Truth about dependency injection
- 1:22:14Final thoughts and Q&A
related talks
01h 01mDependency Injection in C++ - A Practical Guide
01h 02mRefactoring C++ Code for Unit testing with Dependency Injection
01h 03mHow to Use C++ Dependency Injection to Write Maintainable Software
32mCompile- and Run-Time Dependency Injection
58mA Practical Guide to Loose Coupling
01h 28mLaw of Demeter: A Practical Guide to Loose Coupling
05mConcept Driven Design with Dependency Injection
54mDependency Injection revisited
