Hi,

I have a design issue and don;t have a clue how to proceed.

In one of my projects I have to develop a software framework. Users who use the framework should be able to define objects they want to use and their relationship (Similar to class hierarchy).

ex: A owns B
B can-have-a-opinion-on A
B can-have-a-opinion-on B

Where A,B.... will end up as classes in the system. Please note that classes as well as their relationships are defined at runtime (or rather configuration time).

Anyone has any idea how to do the class creation and relationship defining ....

Thanks in advance,
Ishan

Sounds like a graph problem. You can use a graph, where each item (A, B, etc.) are nodes/vertices, and each one-directional link/edge implies a relationship (i.e. owns). There are a few ways to represent graphs in code, one way is with an adjacency list. Essentially this is a 2D list where the first dimension is a list of the objects (A, B, etc) and for each object, there is a list of all the objects it has edges to (owns).

I've never made a graph where there are multiple kinds of relationships, although you could have one graph for each relationship type if that is feasible.

Thanks ! Will try that ....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.