Apply generalization and specialization to define an inheritance hierarchy.
Application of Modeling Generalization
Generalization is a technique for organizing information about objects according to the similarities and distinctions within the set of objects. Generalization is unlike any other kind of association. Associations describe how objects are related to one another. Generalization ties together pieces of class definitions to create one complete class definition.
Generalization uses classes and association lines that you already know. In addition, a triangle is placed at the superclass end of the association instead of an association name. The discriminator is placed on the association line between the superclass and subclasses.
Concepts to watch for
Whenever the problem statement and use cases attempt to describe objects in terms of what they have in common and what distinguishes them, you should start thinking about generalization.
Look for phrases like:
Kind of: "We offer six different kinds of kinds of accounts." "The Z Plan is another kind of corporate account."
Type of: "We support three types of clients..."
Like...but: "Status X is like preferred customer status but with a different qualifications."
similar...but: "This product is similar to product X but with a different widget assembly."
To apply generalization, identify the properties that the objects have in common and the properties that make them different. Let's step through the process used to develop the Customer generalization used earlier.
Begin with a problem statement that describes customers
Identify the properties of customer from the problem statement
Place all properties into a class definition
Select a subclass for each value of the discriminator
Create a subclass to the superclass with a generalization association
Identify the properties that are not common to all types of customers.
Please note that this example used only attributes. However, the process includes distribution of operations and methods (operation implementations) as well.
Modeling Generalization and Customer Generalization
Generalizations may have multiple layers, just like aggregation. Inheritance has received a lot of attention, probably too much. Teachers and designers are now cautioning developers to avoid overusing inheritance. Misuse has arisen primarily because it is so easy to use inheritance to get access to existing code. For alternatives, look into design patterns and specifically a concept called delegation. Delegation is described in the UML Fundamentals course, and is used in many design patterns.