11.4 More on representing classification hierarchies

In section , we discussed how to use subclasses to represent classification hierarchies.

Virtual method and virtual classes provide a further mechanism for representing classification hierarchies. A virtual method or class makes it possible to represent a specialization of a property of a given concept.

Representing specialization using virtual methods

In section , we have an example of representing a travel booking system. A booking of has properties like registration of the booking, cancelation of the booking and confirmation of the booking. These three properties may be represented by methods.

As discussed in section , registration of the booking is the same for all bookings, but cancelation and confirmation depends on whether the booking is a flight booking, train booking, or hotel booking. Cancelation and confirmation may thus be organised in a specialisation hierarchy being nested within the booking hierarchy as shown in the figure.

As can be seen, each booking class/concept has a nested specialization of the confirm method.

Representing specialization using virtual classes

As discussed in section , contextualised concepts may be represented by nested classes. As for properties representing activities, such concepts may be specialized in subclasses of the enclosing class.

For the booking system, a travel booking is characterised by local concept of travel information (class TravelInfo), which is specialized in the specializations of travel booking. In section , we have shown how to represent such a contextualized concept by means of a virtual class. This is illustrated by the figure.

As for the method example, above, each travel booking has a nested specialisation of the travel information concept.

In general we may represent two dimensions of specialization: (1) by means of subclasses, and (2) by means of nested virtual classes.