K
kelvSYC
I'm writing a project where I have something like so:
public class Container {
Vector classAList; // a list of class A
Vector classBList; // a list of class B
}
class A {
B method() { return /* an entry in a Container instance's classBList
*/ }
}
where each instance of class A and class B is associated with a
Container. (ie. a Container's classAList has all of the A instances
that are associated with the Container)
In this case, would it be better to have both be nonstatic member
classes of Container, or have them be a separate class and pass a
Container into its constructor? Should I reconsider my design?
public class Container {
Vector classAList; // a list of class A
Vector classBList; // a list of class B
}
class A {
B method() { return /* an entry in a Container instance's classBList
*/ }
}
where each instance of class A and class B is associated with a
Container. (ie. a Container's classAList has all of the A instances
that are associated with the Container)
In this case, would it be better to have both be nonstatic member
classes of Container, or have them be a separate class and pass a
Container into its constructor? Should I reconsider my design?