views:

53

answers:

2

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:

  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)
A: 

Facade Pattern

tsinik
I've added some clarification I forgot too (sorry)
Greg
+1  A: 

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.

Justin
I've added some clarification I forgot too (sorry)
Greg