class A {
B bObject;
}
class B {
private List<SomeType> list;
public List getList() {return list;}
public void foo(int i) {
list.get(i).someTypeMethod(); // 2 dots
}
}
class SomeType {
public void someTypeMethod() {}
}
Suppose I want to call get on the list from bObject in class A. Should I simply call getList().get(3), or maybe it's better to rewrite a method in the B class that retrieves or adds the element at the specified position from/in the list?
In general, if class B field wasn't a List, but some other class C, should B prevent class A from calling C methods directly?