Once upon a time:
I had a classA which had many fields. I injected class A to classB and class C through their constructors because the last two needed to communicate with classA.
Problem:
So I have done the dependency injection and now I noticed that class B and class C were sad because they couldnt access the fields from class A which were set to private. They tried it through getters but class A quickly became too fat and so both classes wondered if there was a way to access the fields of their dependency without getters and without setting them to public.
Example (Pseudo code!!!):
class A {
 private field1 = 1;
 private field2 = 2;
 private field3 = 3;
 private field4 = 4;
 private field5 = 5;
 private field6 = 6;
}
class B {
    public B(A a) {
      System.out.print(a.field1);
    }
}
class C {
    public B(A a) {
      System.out.print(a.field2);
    }
}
A a = new A();
new B(a);
new C(a);
Inheritance and setting fields to protected would solve things but the problem is each child would have a different parent. I dont want that.
So my question is: How can I access the fields of a dependency without getters or reflection?
 
    