This week's book giveaway is in the Other Open Source APIs forum. We're giving away four copies of Storm Applied and have Sean Allen, Peter Pathirana & Matthew Jankowski on-line! See this thread for details.
Can we replace singleton design pattern by making all the methods of the class as static and declaring all the constructors as private. This way other classes won't be able to instantiate this class and have to invoke methods using class name only. Also which approach will be better performance wise?
Prakash Dwivedi (SCJP2, SCWCD, SCBCD)
"Failure is not when you fall down, Its only when you don't get up again"
Can we replace singleton design pattern by making all the methods of the class as static and declaring all the constructors as private.
Yes you replace singleton by making all methods static. I don't see any performance gain using static methods. I am more comfortable using singleton rather than all-methods-static class implementation even though there is no harm using the latter.