A New Metric for Class Cohesion for Object Oriented
Software
Anjana Gosain1 and Ganga Sharma2
1University School of Information, Communication and Technology, Guru
Gobind Singh Indraprastha University, India
2School of Engineering, G D Goenka
University, India
Abstract: Various
class cohesion metrics exist in literature both at design level and source code
level to assess the quality of Object Oriented (OO) software. However, the idea
of cohesive interactions (or relationships) between instance variables (i.e.,
attributes) and methods of a class for measuring cohesion varies from one
metric to another. Some authors have used instance variable usage by methods of
the class to measure class cohesion while some focus on similarity of methods
based on sharing of instance variables. However, researchers believe that such
metrics still do not properly capture cohesiveness of classes. Therefore,
measures based on different perspective on the idea of cohesive interactions
should be developed. Consequently, in this paper, we propose a source code
level class cohesion metric based on instance variable usage by methods. We
first formalize three types of cohesive interactions and then categorize these
cohesive interactions by providing them ranking and weights in order to compute
our proposed measure. To determine the usefulness of the proposed measure,
theoretical validation using a property based axiomatic framework has been
done. For empirical validation, we have used Pearson correlation analysis and
logistic regression in an experimental study conducted on 28 Java classes to
determine the relationship between the proposed measure and maintenance-effort
of classes. The results indicate that the proposed cohesion measure is strongly
correlated with maintenance-effort and can serve as a good predictor of the
same.
Keywords: Class cohesion, metrics, OO software,
maintenance-effort, metric validation.
Received June 18,
2017; accepted March 11, 2018
https://doi.org/10.34028/iajit/17/3/15