The subclass mechanism as described in chapter makes it possible to represent tree-structured classification hierarchies. In practice, many classification hierarchies are in fact tree-structured, but there are of course examples of the opposite. In this chapter, we show examples of such hierarchies.
The classification of geometric figures may result in a non-tree structured hierarchy as shown below. Here the concept Square has two generalizations, Rectangle and Rhomb.

There are situations where it may be desirable to classify phenomena according to independent properties. People may e.g. be classified according to their nationality and profession as shown in the next figure. This leads to two or more independent classification hierarchies of the same phenomena (in this case people).

A phenomenon may be member of different concepts over time. At one point of time, person may be a student, then a programmer and later a manager as illustrated by the figure below. This form of dynamic classification is not supported by mainstream programming languages. In some languages, like Smalltalk, it is possible to change the class of an object, but this may be an unsafe way of programming and for languages with static type checking, it breaks the type checking.

Language support
All languages have limitations for describing models and the modeler/programmer must be aware of these limitations. If your domain e.g. require non-tree-structured classification hierarchies and your language only support tree-structured classification, you must find a work-around and you need to document that a work-around has been made.
Aspects of a phenomena as described in chapter , may be viewed as a kind of classification of phenomena characterized by a given aspect. The representation of aspects by means of intrinsic objects combined with nesting is in many cases a good solution, buy may also be seen as a work-around.
For independent classification hierarchies, aspects may often be used. Given the concept of a person represented by a class Person
, Nationality
and Profession
may then be viewed as different aspects of a person and thus be represented by intrinsic objects.
In the case of dynamic classification, intrinsic objects cannot be used to represent the actual aspect since such an object is the same for the life-time of the enclosing object. Here a variable reference may sometimes be used, but if the type of the aspect shall be defined using the context of the phenomena/object having the aspect, the class type of the reference must be defined as a local class. But defining the profession hierarchy as local classes of class Person
limits profession to be aspects of only person.
Support in other languages
No mainstream object-oriented language (if any language at all) has a suitable mechanism for representing independent classification hierarchies, although many languages have mechanism intend for this purpose.
Some languages support so-called multiple inheritance, which allows a class to have more than one superclass – examples of such languages are Eiffel, CLOS and C+. This easily leads to a combinatorial explosion of classes like NorwegianNurse
, JapaneseNurse
, NorwegianEngineer
, etc. which in most cases gives a very tangled subclass structure.
Java has an interface-mechanism which is a simplified version of multiple inheritance. An interface is a class with only method-signatures with an empty body. A class may have one superclass but implement zero or more interfaces. Most interfaces only have method signatures, while some languages, e.g. C# support that methods of interfaces may have behaviour descriptions.
Other mechanism are so-called traits and mixins that may be used to represent aspects, multiple inheritance and independent classification hierarchies.
Most of the proposal for multiple inheritance traits and/or mixing have focus on the use of these mechanisms for reuse of code and rarely mention representation of classification hierarchies.
For a detailed description of multiple inheritance, interfaces, traits and mixing, the reader should learn to what extent such mechanism are supported by a given language.