Skip to main content

It depends on the language and the context, sometimes. For example, PHP scripts used for servicing requests always have one request to service and one response to generate throughout the entire lifetime of the script, so static methods to act on the request and generate a response may be appropriate. But in a server written on Node.js, there may be many different requests and responses all at the same time. So the first question is -- are you sure that the static class really corresponds to a singleton object?

Secondly, even if you have singletons, using objects allows you to take advantage of polymorphism using techniques like Dependency_injection and Factory_method_pattern . This is often used in various Inversion_of_control patterns, and useful for creating mock objects for testing, logging, etc.

You mentioned the advantages above, so here is one you didn't: inheritance. Many languages have no ability to override static methods the same way that instance methods can be overridden. In general, it's much harder to inherit and override static methods.