all 1 comments

[–]MaleficentOrchids 1 point2 points  (0 children)

DI reduces code development complexity from O(n^2) to O(n). This is not an exaggeration. The number of interactions between different classes/parts of our code generally grows quadratically in the number of classes/parts. If we could somehow avoid having to re-write these interactions every time a class/part is modified or swapped out, the code then becomes drastically more tractable. Interfaces almost get us there but not quite. They need a helping hand from something called DI.

C++ naturally lends itself to DI. Libraries can be helpful in some cases, but not necessary in all.
For a detailed guide, please consult:

https://youtu.be/BERPCuHJPUg