Could you talk to me a general principle to choose the location of a parameter (attribute) in a class?
For example, I can have a class:
class A {
X x;
Y y;
A (X x, Y y) {...}
void method() {...}
}
Way to use:
A a = new A(x, y);
a.method();
Or I can have a class:
class B {
X x;
B (X x) {...}
void method(Y y) {...}
}
Way to use:
B b = new B(x);
b.method(y);
To rephrase the question: what should I incapsulating and what should I leave as part of the interface?
Aucun commentaire:
Enregistrer un commentaire