开发者

c# - what approach can I use to extend a group of classes that include implemented methods? (see description for more detail)

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 parentN开发者_如何学Pythonode & 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:

  1. 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?
  2. Abstract Classes - would the base classes be abstract classes
  3. Custom Generic Collection - would some approach using this concept assist (but how would this work if there are the 3 different classes)


I would say abstract base classes implementing an interface, with at least one implementation class for each base class. Users could choose to extend the base class or go ahead with a working implementation class or additionally they could just implement the required interface in its entirety.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜