Generalisation and Classification
In this section we are going to work through an example in the course text UML Distilled - 3rd Edition pages 75-76. This provides an excellent example of the differences between classification and generalisation. Let's consider the following phrases describing a dog called Shep.
- Shep is a Border Collie.
- A Border Collie is a Dog.
- Dogs are animals.
- A Border Collie is a Breed.
- Dog is a Species.
Notice the "is a" term. In some cases this can be used to determine whether the relationship between two classes is that of generalisation. Generalisation is transitive therefore we should be able to combine these phrases. Let's have a look at what happens when we do.
Shep is a Dog (1+2)
Border Collies are Animals. (2+3)
Shep is an animal (1+2+3)
Shep is a breed. (1+4)
A Border Collie is a species. (2+5)
As you can see this didn't work for all phrases. This is because some of the phrases were classification whereas some, the ones that worked, were generalisation.
Some of the phrases were classification
Shep is an instance of Border Collie
Others were generalisation
Border Collie is a subtype of Dog
This example highlights that generalisation is transitive whereas classification is not. In short be careful when using the "is a" test to determine if there is an area of generalisation.