5 ms·
DI is nothing else than partially applied functions, which is useful to limit the number of values flowing explicitly to the call point. Limiting the data flow
by pacala 12y ago
DI is nothing else than partially applied functions, which is useful to limit the number of values flowing explicitly to the call point. Limiting the data flow diameter is good, as our brains can handle so much information simultaneously.
On the other hand, DI frameworks are a "modern" way to do global objects. I have no clue what problem they solve or why using a DI framework is a good idea. I've had the "pleasure" to work with a Java DI framework project last week, it turned 10 lines of code into 300 lines of boilerplate spread around 3 different packages.
Furthermore, I agree, the pervasive use of mocks is a smell. The point of tests is to have test suite T.A to validate module A. Littering the test base with mocks of A which don't pass the test suite T.A is just a recipe for pain, both semantically and as increasing the amount of code change required by a refactoring. A is changing? Go chase the 100 mocks that make their own assumptions about A and fix them. Your tests are now part of the liability under change instead of being the safety net that tells you whether your module B depending on A is still working.