c# - what approach can I use to extend a group of classes that include implemented methods? (see des
Posted
by Greg
on Stack Overflow
See other posts from Stack Overflow
or by Greg
Published on 2010-05-04T06:56:17Z
Indexed on
2010/05/04
6:58 UTC
Read the original article
Hit count: 218
Hi,
I want to create an extendible package I am writing that has Topology, Node & Relationship classes. The idea is these base classes would have the various methods in them necessary to base graph traversal methods etc. I would then like to be able to reuse this by extending the package.
For example the base requirements might see Relationship with a parentNode & childNode. Topology would have a List of Nodes and List of Relationships. Topology would have methods like FindChildren(int depth).
Then the usage would be to extend these such that additional attributes for Node and Relationships could be added etc.
QUESTION - What would be the best approach to package & expose the base level classes/methods? (it's kind of like a custom collection but with multiple facets). Would the following concepts come into play:
- Interfaces - would this be a good idea to have ITopology, INode etc, or is this not required as the user would extend these classes anyway?
- Abstract Classes - would the base classes be abstract classes
- Custom Generic Collection - would some approach using this concept assist (but how would this work if there are the 3 different classes)
thanks
© Stack Overflow or respective owner