New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GenericTree<T> can't be properly extended #30
Comments
@bretthysuik so how would you fix this? |
I haven't looked into the other tree implementations so I don't know if the following suggestions would break something outside the scope of ITree
ReadOnlyCollection<ITree<T>> Children { get; }
ITree<T> Add(T item);
BreadthFirstTraverse(IVisitor<ITree<T>> visitor);
DepthFirstTraverse(OrderedVisitor<ITree<T>> visitor); I find GeneralTree
If I have time in the next few days I'll submit a pull request with some or all of these changes. |
I haven't had time to look into fixing this, and it's unlikely I'll have time in the near future. You can close this bug if you want. |
InsertItem
andRemoveItem
can't be properly overridden in a derived class becauseAdd
returns aGeneralTree<T>
instance. Consumers of the derived type have to explicitly cast theGeneralTree
instance returned byAdd
to their derived type in order for the overridden functionality to be called.Example:
I hate to say it, but the entire
GeneralTree<T>
abstraction is broken because of all theITree<T>
explicit implementations and the usage ofGeneralTree<T>
in method signatures instead of the base interface.Declaring
var derivedTree
as anITree<string>
isn't useful because you lose out on all the nice methods inGeneralTree<string>
....The text was updated successfully, but these errors were encountered: