Essence and Metrics

On this page we correlate relative essence to commonly used metrics, as produced by four different tools that operate on Java bytecode:

We measured those metrics at different granularities: class, package, and application. Our corpus consists of 211507 classes that are grouped into 11018 packages which are used by 133 applications. Thus, if we compute a metric on class granularity, we will get 211507 values (a separate value for each class). When we compute a metric on application granularity, we only get 133 values.

Some metrics, such as those representing properties of classes (e.g. "fields per class") can be reported on all three levels of granularity, e.g. 5 fields in class C (F=5), 50 fields in package P, where package P contains 5 classes (F=50/5=10), 500 fields in application A, where application A contains 250 classes (F=500/250=2). Other metrics are not defined on some levels of granularity, or, while they might be defined, they are not reported by the tools.

Using class granularity to compute metrics provides a large number of data points, however, for some metrics it also means that there is a certain problem with the resolution (e.g. there are not too many distinct values for the number of "Final Inner Classes" in a class).

We computed relative essence for each class, for each package, and for each application.

Finally, we computed Pearson's cross correlation coefficient over all data points (all classes, or all packages, or all applications) between the relative essence and the given metric.

Cyclomatic Complexity - cyvis

Cyclomatic complexity is related to the amount of functionalty. We measured cyclomatic complexity with CyVis. In addition to using traditional cyclomatic complexity (per method), we also compute "cyclomatic complexity per (bytecode) instruction".

Metric Granularity Data points Correlation with relative essence
Cyclomatic complexity per Method Class 211507 classes 0.49
Cyclomatic complexity per Method Package 11018 packages 0.207
Cyclomatic complexity per Method Application 133 applications 0.47
Cyclomatic complexity per Instruction Class 211507 classes -0.11
Cyclomatic complexity per Instruction Package 11018 packages -0.128
Cyclomatic complexity per Instruction Application 133 applications -0.17

OO Metrics - JDepend (Package Granularity)

The following table shows the correlation of relative essence with the object-oriented design metrics computed by JDepend. JDepend reports metrics at package granularity.

Metric Correlation with relative essence
Abstractness -0.114
Efferent Coupling 0.053
Abstract Class Count -0.037
Instability 0.029
Afferent Coupling 0.021
Distance from the Main Sequence -0.011
Class Count 0.000

Chidamber-Kemerer Metrics - CKJM (Class Granularity)

The following table shows the correlation of relative essence with the Chidamber-Kemerer Metrics computed by ckjm. Ckjm reports metrics at class granularity.

Metric CK metric? Correlation with relative essence
RFC Response for a Class yes 0.264
CBO Coupling between object classes yes 0.263
WMC Weighted methods per class yes 0.137
NPM Number of public methods no 0.094
Ca Afferent couplings no 0.046
LCOM Lack of cohesion in methods yes 0.026
NOC Number of Children yes 0.014
DIT Depth of Inheritance Tree yes -0.004

Basic OO Metrics - Dependency Finder

The following three tables show the correlation of relative essence with the basic object-oriented metrics computed by Dependency Finder. Dependency Finder reports metrics at class, package, and application granularities.

Basic OO Metrics - Dependency Finder (Class Granularity)

Metric Correlation with relative essence
Local Variables per Method 0.419
Local Variables in Class 0.214
Single Lines of Code in Class 0.196
Ratio of Protected Methods 0.190
Single Lines of Code per Method 0.165
Private Attributes 0.163
Method Parameters in Class 0.159
Method Parameters per Method 0.144
Ratio of Final Attributes -0.131
Methods 0.123
Protected Methods 0.112
Ratio of Private Attributes 0.109
Ratio of Package Attributes -0.104
Ratio of Package Methods -0.103
Public Methods 0.092
Ratio of Public Inner Classes -0.089
Outbound Intra-Package Dependencies 0.082
Outbound Extra-Package Dependencies 0.081
Static Methods 0.079
Ratio of Static Methods 0.071
Ratio of Private Methods -0.064
Ratio of Public Methods -0.063
Ratio of Final Methods 0.062
Ratio of Package Inner Classes 0.058
Ratio of Synchronized Methods 0.056
Final Methods 0.053
Ratio of Synthetic Attributes -0.052
Ratio of Private Inner Classes 0.049
Synchronized Methods 0.046
Package Methods 0.044
Private Methods 0.042
Protected Attributes 0.040
Ratio of Static Attributes -0.039
Ratio of Protected Inner Classes -0.037
Package Inner Classes 0.032
Ratio of Abstract Methods -0.030
Private Inner Classes 0.030
Ratio of Static Inner Classes -0.030
Inbound Extra-Package Method Dependencies 0.030
Inner Classes 0.029
Inbound Extra-Package Dependencies 0.027
Attributes 0.026
Final Inner Classes 0.025
Inbound Intra-Package Dependencies 0.024
Ratio of Synthetic Methods -0.022
Inbound Intra-Package Method Dependencies 0.021
Abstract Inner Classes 0.019
Ratio of Final Inner Classes 0.019
Ratio of Public Attributes -0.017
Static Inner Classes 0.016
Abstract Methods -0.013
Package Attributes -0.012
Ratio of Native Methods -0.012
Volatile Attributes 0.012
Transient Attributes 0.012
Subclasses 0.012
Synthetic Attributes 0.011
Native Methods -0.010
Ratio of Abstract Inner Classes -0.008
Static Attributes -0.008
Ratio of Deprecated Attributes -0.008
Final Attributes -0.008
Ratio of Protected Attributes -0.006
Ratio of Volatile Attributes 0.005
Protected Inner Classes 0.005
Synthetic Methods 0.005
Ratio of Deprecated Methods -0.002
Ratio of Transient Attributes 0.002
Deprecated Attributes -0.001
Public Inner Classes 0.001
Public Attributes 0.000

Basic OO Metrics - Dependency Finder (Package Granularity)

The following table presents the correlation with metrics Dependency Finder computed at package ("group") granularity.

Metric Correlation with relative essence
Single lines of code per class 0.267
Methods per class 0.099
Inner classes per class 0.088
Single lines of code per package 0.076
Methods per package 0.031
Attributes per application 0.029
Attributes per class 0.022
Final classes per class 0.012
Final classes per package 0.012
Inner classes per package 0.008
Classes per package 0.007
Subclasses per package 0.006
Deprecated classes per package -0.004
Public classes -0.006
Subclasses per class -0.007
Deprecated classes per class -0.009
Synthetic classes per package -0.027
Synthetic classes per class -0.028
Abstract classes per package -0.037
Interfaces per package -0.055
Public classes per class -0.087
Interfaces per class -0.117
Abstract classes per class -0.128

Basic OO Metrics - Dependency Finder (Application Granularity)

The following table presents the correlation with metrics Dependency Finder computed at application ("project") granularity.

Metric Correlation with relative essence
Attributes per class 0.224
Single Lines of Code per package 0.191
Final classes per application 0.080
Inner classes per application 0.080
Single Lines of Code per application 0.078
Attributes per project 0.069
Subclasses per application 0.068
Number of classes 0.065
Methods per application 0.065
Classes per project 0.064
Subclasses per class 0.061
Abstract classes per project 0.059
Abstract classes per package 0.056
Interfaces per application 0.056
Public classes per application 0.050
Number of packages 0.046
Classes per package 0.036
Final classes per package 0.035
Interfaces per package 0.031
Public classes per package 0.029
Methods per class 0.016
Inner classes per package 0.013