Parallel hierarchies problem
From CSSEMediaWiki
Revision as of 03:47, 22 August 2008 by Elliot Fisher (Talk | contribs)
The parallel hierarchies problem is when you run into this situation in your design:
You need to have a Vehicle hierarchy for different vehicles, and an Operator hierarchy for different Operators of Vehicles. In this case the operator is stored in the abstract Vehicle class. This means that it is possible that a Plane class could be given a Driver operator, which is obviously invalid.
This problem cannot be completely avoided, but you can structure it in the best possible way by using the Intelligent children pattern and the Defer identification of state variables pattern (which are closely related).
TODO: example of better structure after applying pattern.