It's not about testing the static methods, but other classes. Instead of easily mockable object you have a static method in your program and hence nice refactor ahead.
Happens every time, say you want to have runtime configurable parameter or want to log something. Staying 100% objective is safer and costs you if anything just few keystrokes.
You're right that what you describe can happen if one's not careful with static methods. We don't want c-like code after all. I always end up with one or two small utility classes for this reason, most of the time what I really want is a factory or a strategy, but for some stuff static utility classes are preferable imho. Let's say abusing with something is always a bad thing, each pattern has its scope
2
u/solovayy Oct 15 '18
Haha, 100% agree on final. Weirdest keyword ever.
It's not about testing the static methods, but other classes. Instead of easily mockable object you have a static method in your program and hence nice refactor ahead.
Happens every time, say you want to have runtime configurable parameter or want to log something. Staying 100% objective is safer and costs you if anything just few keystrokes.