3 ms·
Composable maybe, but testable, not necessarily. If the function doesn't read or modify a global state, it can be much easier to test in isolation than a class
by jbay808 6y ago
Composable maybe, but testable, not necessarily.
If the function doesn't read or modify a global state, it can be much easier to test in isolation than a class, which might e.g. throw an exception in the constructor causing your test to fail before you even get to run your method.
If it does touch a global state, it's probably instead better as part of a class.