Problem Analysis  «Prev  Next»
Lesson 13Modeling generalization
ObjectiveApply 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 diagram consisting of 1) Customer, 2) PrivateCustomer and 3) CorporateCustomer

Modeling Elements

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.

Generalization uses Classes

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:
  1. Kind of: "We offer six different kinds of kinds of accounts." "The Z Plan is another kind of corporate account."
  2. Type of: "We support three types of clients..."
  3. Like...but: "Status X is like preferred customer status but with a different qualifications."
  4. 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.

  1. Begin with a problem statement that describes customers
  2. Identify the properties of customer from the problem statement
  3. Place all properties into a class definition
  4. Select a subclass for each value of the discriminator
  5. Create a subclass to the superclass with a generalization association
  6. Identify the properties that are not common to all types of customers.
  7. Please note that this example used only attributes. However, the process includes distribution of operations and methods (operation implementations) as well.

Business 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.

Modeling Generalization - Exercise

Click the Exercise link below to model generalization examples taken from the course project problem statement.
Modeling Generalization - Exercise