-4

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.

Community
  • 1
  • 1
Popcorn
  • 5,188
  • 12
  • 54
  • 87

1 Answers1

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