Sometimes it’s very difficult to find an error in an application because of static data. Is it a good approach to use static data in OOP or is it better to avoid it?
Thanks in advance.
UPDATE:
How often are you using static classes and for what purposes?
Generally speaking
staticmethods leads to code that is hard to test sinceThere are a few valid use cases though.
An example of the latter could be
I would normally refrain from using
staticmethods and let the default principle be that the existence of anystaticcontent needs to be motivated.As pointed out by @Louis,
staticvariables are useful to provide single instance constants. Typically this can also apply to member variables holding objects such as a Logger.