14 ms·
" I cringe every time I see a senseless/useless DI/IoC system in JS that adds nothing but indirection and complexity (looking at you Angular)." Isn't it suppos
by collyw 11y ago
" I cringe every time I see a senseless/useless DI/IoC system in JS that adds nothing but indirection and complexity (looking at you Angular)."
Isn't it supposed to make testing easier? (Personally I never managed to get the Angular hype, but I am a Python dev mainly).
- tracker1 11y agoIf you're doing node-style (cjs) modules, you can use something like proxyquire[1] with testing to inject dependencies without complicating your modules, or creating logical indirection. If the only reason you have DI is for testing in a scripted platform, you're probably doing something wrong. You can write, compose and composite plain objects and pure functions in JS modules that can be tested very easily without resorting to complex DI systems (with naming disconnects even). [1] https://www.npmjs.com/package/proxyquire https://www.npmjs.com/package/proxyquire