Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This will vary from firm to firm depending on what you're writing, but I generally find DI to be more complexity than needed. Granted,

- I'm willing to rewrite some code if we decide that a core library needs to get swapped out

- I'm always using languages that allow monkey-patching, so I'm not struggling to test my code because, for example, it's hard to substitute a mock implementation for `Date.now()`.

DI makes more sense if you're not in that position. But in that position, DI adds "you need these three files in your brain at the same time to really understand what's going on" complexity that I seek to avoid.

(Also, DI overlaps with generics, and to the extent that you can make things generic and it makes sense to do so, you should).



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: