How to design this class hierarchy?
Posted
by devoured elysium
on Stack Overflow
See other posts from Stack Overflow
or by devoured elysium
Published on 2010-04-01T21:22:47Z
Indexed on
2010/04/01
21:33 UTC
Read the original article
Hit count: 366
I have defined an Event class:
Event
and all the following classes inherit from Event:
AEvent BEvent CEvent DEvent
Now, with the info I gather from all these Event classes, I will make a chart. With AEvent and BEvent, I will generate points for that chart, while with CEvent and DEvent I will paint certain regions of the chart.
Now, how should I signal this in my class hierarchy?
- Should I make AEvent and BEvent inherit from PointEvent while CEvent and DEvent inherit from RegionEvent, being that both RegionEvent and PointEvent inherit from Event?
- Should I add a field with an Enum to Event with 2 values, Point and Region, and each of the child classes set their value to it?
- Should I use some kind of pattern here? Which one?
Thanks.
© Stack Overflow or respective owner