To extend a bit on the title, I'm trying to get to some conclusion about whether it is necessary or not to explicitly declare (i.e. inject) pure functions on which some other function or class depends.
Is it any given piece of code less testable or worse designed if it uses pure functions without asking for them? I would like to get to a conclusion on the matter, for any kind of pure function from simple, native functions (e.g. max()
, min()
– regardless of the language) to custom, more complicated ones that in turn may implicitly depend on other pure functions.
The usual concern is that if some code just uses a dependency directly, you will not be able to test it in isolation, namely you will be testing at the same time all that stuff that you silently brought with you. But this adds quite some boilerplate if you have to do it for every little function, so I wonder if this still holds for pure functions, and why or why not.