|
|
|
|
|
by cjsuk
3153 days ago
|
|
Problem is that the moment you start introducing delegates and crap like that is you're inventing a mechanism to work around your resistance to not using static methods rather than actually solving any problems. There is no functional difference between a class with static methods and a class without, of which one instance is available to other classes. Other than the fact that it isolates state, allows mocking and substitution and testing. |
|
Static methods usually don't rely on any hidden state at all. The example originally given was for a graph operation which could just take the input graph as an argument and return the result. When your code is composed of small independent functions you don't need mocking and substitution at all. In my experience most uses of mocks come from functions that do too much in the first place.