Daily bit(e) of C++ | dependency injection
Daily bit(e) of C++ ♻️117, Decoupling a component from the concrete implementation of a dependency using dependency injection.
Dependency injection is a straightforward design pattern that decouples a component from the concrete implementation of a dependency.
While the pattern introduces a virtual dispatch (with its runtime cost), its simplicity and effect on testability are usually worth it.
It's a great idea to have a short overview of design patterns.
Can we use CRTP or C++23 deducing this as well without the virtual dispatch.