|I l @ ve RuBoard|
The basis for specialization (i.e., why subclasses were created) in an inheritance relationship is called the discriminator. The discriminator typically has a finite set of values and subclasses that may be created for each value. For example, one basis for discrimination for a Course class is the location of the courseOnCampusCourse and OffSiteCourse could be two subclasses of the Course class based on this discriminator. The inheritance relationship may be shown as a tree for all subclasses created from one discriminator. Another subclass of Course could be MandatoryCourse. This subclass would not be part of the inheritance tree because it belongs to a different discriminatorcourse type. Care must be taken when you discover multiple discriminators for a classfor example, what happens when a mandatory course is held on campus. Do you have a multiple inheritance situation? Should aggregation be used? As analysis and design progresses, the answers to these questions will lead to the structure of the model.
CREATING AN INHERITANCE TREE IN RATIONAL ROSE
An inheritance tree may be created from two separate generalization arrows by selecting one arrow and dragging it onto the other arrow.
An inheritance tree relationship is shown in Figure 8-2.
Figure 8-2. Inheritance Tree
I also like to show stereotypes as labels in this type of diagram since the inheritance triangle may obscure the class name if an icon is used.
Attributes, operations, and relationships are relocated to the highest applicable level in the hierarchy once a superclass is created. What features should be relocated ? Let's look at the RegistrationUser hierarchy. The attributes, operations, and relationships for the subclasses are shown in Figure 8-3. As long as name and IDNumber have the same format they may safely be moved to the superclass (RegistrationUser). Both classes have a relationship to the CourseOffering class. There are two options that may be chosen for this relationship:
Figure 8-3. RegistrationUser Inheritance Hierarchy
Which way is correct? They both are. Which way is the best to use? It depends. If you have a need for a CourseOffering object to know all the students and the professor, then having one list containing this information might be handy. This would imply that the second option is the way to go. If, on the other hand, you need to know only students or professors but not both at the same time, then the first option is probably best. It all comes down to what the system needs to do! This will be discovered by carefully examining the use cases and scenarios to discover the needed behavior.
RELOCATING ATTRIBUTES AND OPERATIONS IN RATIONAL ROSE
Relocated attributes are shown in Figure 8-4.
Figure 8-4. Relocated Attributes and Operations
|I l @ ve RuBoard|