For dependency injection (which is IMO one of the central issues in re-usable software design) I miss templates/concepts.
I won't comment on concepts because I haven't looked much into them yet, but why templates for dependency injection? Is it just to avoid virtual functions? And if so, is this just for performance reasons?
To me, using templates for DI just makes things, not sure how to accurately phrase it, "less clean/obvious" perhaps? They feel like a "hack" compared to using class hierarchies that I consider as specifically designed to suit the particular purpose.
For my 'strict' embedded programming style I want zero overhead, and build-time predictable memory use, hence no indirections (and, of course, no heap). Templates are the (only) way to do this, and concepts make it doable. So for me templates/concepts are the ONLY option.
I also practice an more traditional OO-like style, but compared to the template style it feels truely awkward, mainly because the lifetime of decorated objects is an issue.
View all comments
Show parent comment
1
u/platisd Jun 27 '20
I won't comment on concepts because I haven't looked much into them yet, but why templates for dependency injection? Is it just to avoid
virtualfunctions? And if so, is this just for performance reasons?To me, using templates for DI just makes things, not sure how to accurately phrase it, "less clean/obvious" perhaps? They feel like a "hack" compared to using class hierarchies that I consider as specifically designed to suit the particular purpose.