This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
"Why is it that helper / Utility classes only contain static Methods"??
I got this query when i am working on a Factory Pattern in which there is a static method that will return the appropiate Object depending upon the data passed to it .
Helper Class mainly have private constructor as well because of which it can not be extended and instantiated.So the only way to access the functionality/methods is to keep the methods static.This also helps Helper/Utility class to keep its functionality secure from unwanted overriding the method funtionality.
It's because it's assumed there's no *reason* to instantiate it (but this is arguable)--if you don't *need* anything other than static methods, why make it instantiable or provide any non-static properties/methods?
On the other hand, purely static classes are more of a pain to use when testing the classes that use them, and although there are mocking libraries that can work around this, I'm not a big fan.