Inheritance Graph Model

An inheritance graph model represents the use of inheritance in a software system. The description given here is specific to the Java Programming Language.

An inheritance graph model is a graph where the vertices are Java reference types (that is, classes, interfaces, enums, annotations) identified by their fully-qualified name. Whenever one type C has an inheritance relationship with another type P, there is a directed edge C->P.

Edges can have attributes. The attributes indicate various properties of the inheritance relationships. For example, some inheritance relationships are explicit, meaning they are described directly in the code (via extends or implements in the type declarations). Other relationships are implicit, meaning they are not described in the code, but are implied by other explicit relationships. For example, if G extends C and C implements P, then there is an implicit relationship between G and P.

Once the attributes have been determined, various inheritance metrics can be defined using expressions indicating the presence or absence of specific attributes. For example, a metric for the number of inheritance relationships between classes (attribute CC) defined for the system under investigation (UserDefined), for which there was external reuse but not subtype use, a metric named nCCExreuseNoSubtype, can be defined as

(UserDefined) and (Explicit) and (CC) and (DirectExReuseField or IndirectExReuseField or DirectExReuseMethod or IndirectExReuseMethod) and (not DirectSubtype) and (not IndirectSubtype)
In other words, nCCExreuseNoSubtype is the number of edges that have all of the attributes UserDefined, Explicit, and CC, have at least one of the attributes DirectExReuseMethod, IndirectExReuseMethod, DirectExReuseField, or IndirectExReuseField, and have neither the DirectSubtype nor IndirectSubtype attributes.

Other indirect metrics can be defined in terms of metrics like that above. E.g. pCCExreuseNoSubtype is the ratio of nCCExreuseNoSubtype to nCCUsed.