3 ms·
Small functions, sure. The most common case of this I've run into is should I use dependency injection just for testing. My function creates a Frob and interac
by iudqnolq 6y ago
Small functions, sure.
The most common case of this I've run into is should I use dependency injection just for testing. My function creates a Frob and interacts with it. By default Frobs persist changes to a DB and sync over the network. I don't want to do that in a test. Now I need to pass a frobFactory of (FrobConfig) -> Frob to my function.
Sure in theory I could use my new configurability for all sorts of things, but in practice I only end up using the alternative path in tests.
When do you not end up needing something like this?