Law of Demeter: A Practical Guide to Loose Coupling
summary
Shows concrete before/after C++ code: a god-object using singletons and chain calls like manager.instance.getSpeakers.get that is hard to test, then refactors with one dot via constructor injection, SRP, dependency inversion and manual DI. Demonstrates runtime options (type erasure, std::variant, std::function) and compile-time options (C++20 concepts, templates) and wires modules in main. Argues DI frameworks are optional, warns about over‑engineering and leaky abstractions, and recommends TDD/BDD to drive a testable, loosely coupled design.
AI-written summary · about
chapters (21)
- 0:00Introduction and overview
- 1:06Software design philosophy
- 5:37The importance of change
- 8:58Core design principles
- 11:17Stupid principles example
- 22:31Testing tight coupling
- 27:22Law of Demeter
- 29:02Refactoring with Demeter
- 31:15SOLID principles overview
- 35:08Single responsibility
- 36:38Loose coupling improvement
- 38:37Dependency injection
- 42:50DI myths
- 44:06DI and singletons
- 44:46Leaky abstractions
- 46:34Strong typing
- 46:55Combining parameters
- 47:28Dependency inversion
- 49:57Concepts and C++20
- 55:28Composition over inheritance
- 56:17Conclusion and TDD/BDD
related talks
58mA Practical Guide to Loose Coupling
01h 29mDependency Injection in C++ - A Practical Guide
05mConcept Driven Design with Dependency Injection
01h 02mAdvanced Levelization Techniques (part 2 of 3)
01h 40mDesign Patterns: Examples in C++
01h 16mPolymorphism, Cohesion, and Coupling in C++
01h 07mDesign Patterns in Modern C++
41mAchieving Loose Coupling with Pure Dependency Injection
