- Should you forget that they ever existed? No.
- Do you need to make sure that they are included in your code in such a way that they are transparent to the functionality of the class? Yes.
To explain this last part further, instead of trying to get the value from singleton code inside your code, try initializing the value in the constructor argument. If your constructor is too large, create a factory method to create so you can test your class without using a singleton. If this turns out to be problematic, or your singleton has a mutable state (I would be afraid of this, but, hey, this is me), then try it so that your singleton is as easily included in your testing as possible.
You do not need to create the entire configuration file to check the class method, which calculates the standard deviation of the stock quotes block over a 4-hour period. This is too much work. But if your singleton is written in such a way that you can fill it with data, and another class should be responsible for reading in the configuration file and filling this data, then you have taken great steps forward.
Regarding static methods, I would say that they are the most easily verifiable methods that you could write based on the condition that you do not need to worry about the global state. The static equivalents y = f(x) , which seem simplified, but underlie the fact that no local state transitions can change the invariant, which for a given x you always get the same y .
source share