3 ms·
I don't think, in the limit, that this is a scalable approach. While I think injecting dependencies is fine in some cases, large programs might have hundreds or
by obstinate 9y ago
I don't think, in the limit, that this is a scalable approach. While I think injecting dependencies is fine in some cases, large programs might have hundreds or thousands of collaborators. It is simply not feasible to instantiate all of them in the main function then pipe all of them down to the package that uses them. This is especially true when you keep the interface small like this program seems to.
I think making the dependency explicit is good when it is likely that it is going to be desired to change the implementation on a per object basis. If it's unlikely or meaningless to have multiple different implementations within the same process, there's nothing wrong with making the configuration global.
Imagine how painful it would be to use the http module if it required the injection of its clock, compression suite, network interfaces, address resolvers, loggers, etc. And that's just one module of many.