the question is simply a design question.. i mean how to restructure this piece of code into something that simple and efficient.
So lets take the following code for example.
class D{
var a;
}
class C{
D d;
//uses d.a
}
class B{
C c;
}
Class A{
B b;
//needs d.a
}
here class A needs to access the variable "a" in D and classes B And C don't store variable "a" (even though C uses "a" i doesn't store it as it only needs it for initialization). Is there a way to make this code more cleaner.
right now i have made both classes B and C store variable "a". but it seems like it's not the correct way to do it. i mean i am thinking of cases where this chain is longer and the last class needs some variable in the first class. so how should i deal with it.