

OOP Alternative to Utility Classes - yiransheng
http://www.yegor256.com/2014/05/05/oop-alternative-to-utility-classes.html

======
sparkie
Please don't do this. This is a perfect example of where living inside your
OOP bubble too long has a net negative effect. You really want to construct a
new object, set two fields, and invoke a method call to find the maximum of
two numbers? This is nothing short of madness.

I'd pick the util method any day, as much as I dislike "Utils" classes. It's
not because they're bad code, it's more because they're disorganized (no
cohesion). The "solution" would suffer exactly the same problem of
organization depending on what namespace you decide to dump the "Max" class
in.

There is nothing wrong with having static classes with static methods which
are completely stateless. That java decided to omit plain functions from the
language was a big mistake, so settling for the next best thing when _a
function is precisely what we want_ is the sane thing to do.

A nicety that C# will have now is that you can import static classes as if
they were namespaces, thus removing the need to continually write "Utils"
everywhere, you can just stick the static method name, and only use "Utils" to
disambiguate if necessary.

