3 ms·
I do personally think it's preferable for components to have their dependencies injected in some way, and that it's better to have initialisation logic (especia
by Tainnor 3y ago
I do personally think it's preferable for components to have their dependencies injected in some way, and that it's better to have initialisation logic (especially related to heavy weight components) in one place.
That doesn't mean that you need some huge ass meta-framework for it though. Just have your main function assemble the components together, done.
- valand 3y agoEven this is an over simplification of inversion of control. Dependency injection is one form, but even a library that exposes parameters is also a form of inversion of control. The degree of control is what varies, whether it is a mere flag (boolean), a variant directive (complex struct), a turing complete construct (pointer of instantiated function) or anything in between. What I am saying is that this concept has been reduced as it is popularized and it isn't doing justice to the original powerful concept.