zooxmusic1
24 Jun 2009, 9:17 AM
Can someone please explain the reasoning behind the change
Removed parent generic from TreeModel.
which reveals the fact that TreeModel's children is a list of ModelData instead of a list of itself (TreeModel). This breaks the composite pattern and makes is awkward at best for recursion.
I feel we should absolutely be able to do
public void someMethod(List<TreeModel> children) {
for(TreeModel child : children) {
//step down through tree
someMethod(child.getChildren());
}
}
but this is impossible now. Shouldn't a tree follow the composite pattern?
Have I been drinking too much lately and overlooking something obvious?
Thanks
Removed parent generic from TreeModel.
which reveals the fact that TreeModel's children is a list of ModelData instead of a list of itself (TreeModel). This breaks the composite pattern and makes is awkward at best for recursion.
I feel we should absolutely be able to do
public void someMethod(List<TreeModel> children) {
for(TreeModel child : children) {
//step down through tree
someMethod(child.getChildren());
}
}
but this is impossible now. Shouldn't a tree follow the composite pattern?
Have I been drinking too much lately and overlooking something obvious?
Thanks