I encountered some code at work that got me thinking.
There was a util - class that had some methods that had nothing to do with the state of the class. They were all "util" methods. Meaning that they could all be declared static with no problem because the only thing they did was some calculations and return the result.
But methods were declared non-static and the class was created as singleton. So even though an instance was needed to call them, because the class was singleton only one instance was created in the end.
I asked the programmer why the methods weren't declared static, and I was told that it is better to a have the class as singleton, than have the methods static.
I search the net for an answer:
http://forums.sun.com/thread.jspa?threadID=672775&start=0&tstart=0
http://blogs.msdn.com/scottdensmore/archive/2004/05/25/140827.aspx
http://www.ibm.com/developerworks/webservices/library/co-single.html
And the conclusion that i came is that it depends on the way you want to use the singleton class. Sometime it is better and sometimes you should avoid it depending on the implementation and how you want to use it.
Now I believe that the methods should be static in the case I described. What I would like, is a response about this comment:
I was told that it is better to a have the class as singleton, than have the methods static
Do you agree or not?