OOPortal OOPortal

Logical View  «Prev 

UML Generalization

A generalization is a directed relationship between a more general classifier (superclass) and a more specific classifier (subclass). A typical example of generalization involves the personal and corporate customers of a business. They have differences but also many similarities. The similarities can be placed in a general Customer class (the supertype), with Personal Customer and Corporate Customer as subtypes. This phenomenon is also subject to various interpretations at the various perspectives of modeling. Conceptually, we can say that Corporate Customer is a subtype of Customer if all instances of Corporate Customer are also, by definition, instances of Customer. A Corporate Customer is then a special kind of Customer. The key idea is that everything we say about a Customer:
  1. associations,
  2. attributes,
  3. operations
is true also for a Corporate Customer.
From a software perspective, the obvious interpretation is inheritance:
The Corporate Customer is a subclass of Customer.
In mainstream OO languages, the subclass inherits all the features of the superclass and may override any superclass methods.

Dog Generalization Diagram

To start the model,begin with the Dog class.

Identify the discriminator for the next level of differentiation or specialization, for example, Breed.

Connect all of the Breed level classes to the Dog class using the generalization type of association, the triangle at the superclass end of the association.

Place the discriminator on the generalization line.

To further specialize the hierarchy, select the discriminator for the next level. For example, break down Breed into sub-breeds, or sub-classes of the Spaniel class.

Connect the new sub-classes to the Spaniel class, again using the generalization symbol. Place the discriminator on the generalization line.