I recently inherited a 10-year code base with some interesting patterns. Among them are static variables inside instance methods. Only one instance of the class is instantiated, and I can hardly find a reason to justify the existence of these static variables in instance methods.
Have you ever developed instance methods with static variables? And what are your rationales?
If this template is considered unsuccessful, then how to fix it?
Note. This question does not apply to Static Variables in Instance Methods
Some reading:
An alternative to singleton is purely static objects. This question has a good discussion.
About the only time when I used static fields in an unstable class was constant.
, , , (, , ). . , , - .
, .
, - , , -, . , , , .