Assuming I have this:
public class A {
private B b;
public B getB() {
return b;
}
}
Now I have a class that needs both B. The problem is whether the constructor should accept only A, and then I will ask B from A, or if the constructor will request both A and B?
Should it be:
public MyClass(A a) {
this.a = a;
this.b = a.getB();
}
or that:
public MyClass(A a, B b) {
this.a = a;
this.b = b;
}
p / s: I think these are pretty unnecessary questions, but whatever.
p / p / s: Thinks it was a community wiki? However, I do not have sufficient permission.: /
source
share