Having read Difference between static class and singleton pattern?, none of the answers list any advantages for using a static method over a singleton, which leads me to wonder why anyone would ever want to use static methods.
Asked
Active
Viewed 231 times
-4
-
I am asking for advantages of using static methods in case that wasn't clear... – Popcorn Aug 09 '13 at 21:07
-
3Motorbike is not called anti-vehicle, while singleton is largely marked with anti-pattern, even thought it might seem to help. – LMG Aug 09 '13 at 21:08
-
1@JasonC that was so ironic, I just had to vote like that as well... – Geeky Guy Aug 09 '13 at 21:09
-
@JasonC answering and duplicate marking?? – Narendra Pathai Aug 09 '13 at 21:10
-
1@NarendraPathai Yes. Any other questions? :) – Jason C Aug 09 '13 at 21:10
-
@JasonC I will post them as a separate post for you to answer! – Narendra Pathai Aug 09 '13 at 21:11
-
1It would be foolish to create a singleton purely to allow one to call what is essentially a static method. Understand the difference between static methods and static data. – Hot Licks Aug 09 '13 at 21:11
-
4Hint: Look at class java.lang.Math, and explain how using a singleton to address one of those methods would do anything other than add overhead and complexity. – Hot Licks Aug 09 '13 at 21:14
1 Answers
5
As with all questions of this nature, use the right tool for the job. Use a singleton when your class represents an object that there can be only one of. Use static methods when your methods are appropriate for the class they are members of but do not rely on a specific instance of that class.
In general, use your best judgment. Go for clean, precise, maintainable code, keeping the overall big picture in mind.

Jason C
- 38,729
- 14
- 126
- 182
-
One important specific case: a singleton class often has a static getInstance method to give users access to the singleton. – Patricia Shanahan Aug 09 '13 at 21:22
-
Down voter please add something constructive. Additional opinions are valuable here. :) – Jason C Aug 14 '13 at 20:23