I hope I can phrase this question correctly. I have a concern when dealing with state and test-ability in classes with static and instance mutable fields.
Do the static fields essentially constitute a different class/responsibility/instance due to the difference in their lifetime/scope?
If so: then shouldn’t the instance fields also be a separate class/data structure?
And then: and if that is so, then shouldn’t all classes be stateless only receiving their dependencies on construction and should all then be immutable?
And finally, would this mean that functional programming is the right way to do object oriented programming as well?
You shouldn’t have (really) mutable static fields. That is crappy design. Functional programming makes things a lot easier. I would separate the concerns so:
database connections, requests etc. This is either from an active
request , or it is pure configuration (injected)
etc..
For testability
In essence ALL of this could be done in a functional way if database (disk) and the request layer (web, ui, whatever) would comply. In practise you try to do the “pure” part in between pretty and functionalish , and use design patterns to shield it from the outside dirt.