Hi,
i am having trouble solving a design problem i'm sure is common,
and wanted some help.
for berevity i'll skim the problem to a smaller example.
I have a design where a base class is called SEGMENT and inheriting from it is FLOW. in SEGMENT i keep a List Of BaseObjects, BaseObject is a Class which FlowObject Inherits From.
the relationship should be:
Segment<---Flow
BaseObject<---FlowObject
and Segment Has A List Of BaseObject, Flow Has A List Of FlowObject,
i though i would keep a member in segment of List<BaseObject>
and would use in Flow the same member to keep the inherited classes FlowObjects as well.
Keeping the list in the base is helpful to me because there are operations that happen on all baseobjects/flowobjects ( such as save to disk / print, etc. )
but going to code testing, i descovered that some classes will need to use the List of FlowObjects outside a Flow, and that would require a casting from the base to the child for each class which is O(n) time and is wasteful.
this seems like a common issue. -- containment of 1:n classes in another class, both with their own inheretance. Any ideas?
Thanks,
Koren.