Logo

11.1.2 Types

Types are central to object-oriented systems. In this section, we take a closer look at the type hierarchy and related classes.

The root of the hierarchy is simply Type . This is a generic class representing a type in an object-oriented language. It can have many Methods and Attributes.

A type can also take part in inheritance relationships. This happens by means of Inheritance entities that connect pairs of types. Multiple inheritance is modeled by simply having multiple inheritance objects connecting the same subclass with multiple superclasses.

Type has several specializations for specific kinds of types. The most prominent is provided by Class. This models a typical class in Smalltalk, Java or C++, but it also models a Java interface (by means of the isInterface boolean property).

A PrimitiveType is just that: a primitive type. For example, int or char will be modeled using PrimitiveType entities.

ParameterizedType and ParameterizableClass model Java generics or C++ templates. In particular, a ParameterizableClass represents the generic definition, while the ParameterizedType represents the actual usage of the generic in a specific context.

Let me provide an example based on the following Java snippet:

public class ClassA<B,C> {...}
...
public ClassA<ActualTypeA,ActualTypeB> anAttribute;

In this case, ClassA will be represented by a ParameterizableClass, and the declared type of anAttribute will be an actual ParameterizedType linking to ClassA. Furthermore, B and C will be ParameterTypes, and the corresponding slots from the ParameterizedType will point to the actual types ActualTypeA and ActualTypeB.

The type hierarchy and related associations

Add a Note