OOP Design: relationship between entity classes

Posted by beginner_ on Programmers See other posts from Programmers or by beginner_
Published on 2012-11-15T06:24:49Z Indexed on 2012/11/15 11:22 UTC
Read the original article Hit count: 174

Filed under:
|
|
|

I have at first sight a simple issue but can't wrap my head around on how to solve. I have an abstract class Compound. A Compound is made up of Structures. Then there is also a Container which holds 1 Compound.

A "special" implementation of Compound has Versions. For that type of Compound I want the Container to hold the Versionof the Compound and not the Compound itself.

You could say "just create an interface Containable" and a Container holds 1 Containable. However that won't work. The reason is I'm creating a framework and the main part of that framework is to simplify storing and especially searching for special data type held by Structure objects. Hence to search for Containers which contain a Compound made up of a specific Structure requires that the "Path" from Containerto Structure is well defined (Number of relationships or joins).

I hope this was understandable. My question is how to design the classes and relationships to be able to do what I outlined.

© Programmers or respective owner

Related posts about design

Related posts about object-oriented