r/cpp • u/Acrobatic-Stable2537 n0F4x • Jun 25 '26
C++23 Dependency Injection library with automatic dependency building
I open-sourced my dependency injection library.
Link: https://github.com/n0F4x/redi
This was developed for my game engine.
- feature-rich dependency configuration
- optimized for fast compile time
- helpful error messages when a cyclic dependency is detected
- dependencies are automatically constructed - no need to register them by hand
I am giving this project to the community so that everybody can benefit. This kind of approach is mostly useful when dealing with intricate systems, such as a plugin system. I welcome all kinds of feedback, as this was mostly a learning opportunity for me. If you'd like to use this in your project but don't have access to the required compiler features, let me know, and I'll see if I can reduce the requirements.
View all comments
Show parent comment
1
u/oracleoftroy Jun 27 '26
To be honest, this sounds like you are writing more and more in a OOP style to me. "Favor composition over inheritance" has been a key object oriented design principle for as long as I can remember, going back at least 30 years. Though nowadays, people seem to speak about OOP as if all it is is inheritance (and factories).
I've long been of the opinion that projects should use inheritance as much as they need to, and that often that number is zero. Objects are very useful on their own without inheritance.
Though, my whole way of thinking about objects revolves around the C++ spec's idea of objects, which it gets from the C spec's idea of objects.