So here is my problem:
For instance, consider that:
A File
has a set of Classes
, as well as Imports
.
A Class
has a set of Instance Methods
, Static Methods
and Variables
.
A Instance Method
has Parameters
and a Body
.
The Body
has ... yadayada.
The problem, when modelling this in a OO way is that Body
may need a lot of specific dependencies to function:
class Body {
...
public Body(Dependency1, Dependency2, Dependency_n, ...) { }
...
}
that all the other classes won't need, to run. The question I'm putting here is on how to get those dependencies to Body
without having to pass all this dependencies through File
, Class
and InstanceMethod
.
I could create a BodyFactory
, but the problem would still be the same, as I'd have to pass the BodyFactory
through File
, Class
and InstanceMethod
, if I'm not missing anything.
How to solve this issue without resorting to singletons?