class - Java: when would I ever want to use static methods when I can use a singleton instead? -
this question has answer here:
having read difference between static class , singleton pattern?, none of answers list advantages using static method on singleton, leads me wonder why ever want use static methods.
as questions of nature, use right tool job. use singleton when class represents object there can 1 of. use static methods when methods appropriate class members of not rely on specific instance of class.
in general, use best judgment. go clean, precise, maintainable code, keeping overall big picture in mind.
Comments
Post a Comment