Object Oriented Software Engineering   View all facts   Glossary   Help
subject > pattern > design pattern > general hierarchy
Next design patternimmutable    Updesign pattern    Previous design patternfacade   

general hierarchy
subjectfact 
general hierarchyhas definition A pattern in which two classes are related both by a generalization and by a one to many association, such that the generated graph of instances forms a hierarchy2001-08-30 14:55:41.0
has antipatterns modelling a hierarchy of categories using a hierarchy of classes2001-08-30 14:55:41.0
has context many class diagrams where you often find a set of objects that have a naturally hierarchical relationship.2001-08-30 14:55:41.0
has forces
  • You want a flexible way of representing the hierarchy that naturally prevents certain objects from having subordinates
  • You also have to account for the fact that all the objects share common properties and operations
2001-08-30 14:55:41.0
has problem How do you draw a class diagram to represent a hierarchy of objects, in which some objects cannot have subordinates?2001-08-30 14:55:41.0
has related patterns the Reflexive Association pattern, the Composite pattern (a specialization of the General Hierarchy pattern)2001-08-30 14:55:41.0
has solution
  1. Create an abstract «Node» class to represent the features possessed by each object in the hierarchy.
  2. Then create at least two subclasses of the «Node» class.
  3. One of the subclasses, «SuperiorNode», must be linked by a «subordinates» association to the superclass; whereas at least one subclass, «NonSuperiorNode», must not be.
  4. The subordinates of a «SuperiorNode» can thus be instances of either «SuperiorNode» or «NonSuperiorNode».
2001-08-30 14:55:41.0
is a subtopic of 6.3 - The General Hierarchy Pattern2001-08-30 14:55:41.0
is an instance of design pattern2001-08-30 14:55:41.0
design patternhas name2001-08-30 14:55:16.0
has references one or more references which indicate who developed or inspired a pattern2001-08-30 14:55:16.0
should be illustrated using a simple diagram2001-08-30 14:55:16.0
should be written using a narrative writing style2001-08-30 14:55:16.0
patternshould be as general as possible2001-08-30 14:56:56.0
should be described in an easy-to-understand form so that people can determine when and how to use it2001-08-30 14:56:56.0
should contain a solution that has been proven to effectively solve the problem in the indicated context2001-08-30 14:56:56.0

Next design patternimmutable    Updesign pattern    Previous design patternfacade