Revising cohesion measures by considering the impact of write interactions between class members

https://doi.org/10.1016/j.infsof.2008.05.014Get rights and content

Abstract

Cohesion refers to the degree of the relatedness of the members in a class and several cohesion measures have been proposed to quantify the cohesiveness of classes in an object-oriented program. However, the existing cohesion measures do not differentiate write interactions from read interactions between class members, thus, do not properly reflect the cohesiveness of the class. This paper presents the revised versions of the existing five cohesion measures by considering the impact of write interactions between class members. In addition, we prove that the revised measures can be reduced into the original ones. To demonstrate the importance of write interactions, we have developed tools for automatic computation of the original and the revised cohesion measures and performed a case study where we found that write interactions are so commonly used in classes that they have much influence on cohesion measurement and the revised measures have stronger relations with change-proneness of classes than the original ones.

Introduction

Cohesion refers to the relatedness of the elements in a module [23]. A highly cohesive module is one whose elements have tight relationships among them in order to provide a single functionality of the module. On the contrary, a low cohesive module has some elements that have little relation with others, which indicates that the module may contain several unrelated functionalities. It is widely accepted that the higher the cohesion of a module is, the easier the module is to develop, maintain, and reuse.

In the object-oriented paradigm, various cohesion measures for classes have been proposed [3], [10], [13], [14], [22], [18], [21]. In the beginning of research on cohesion measures for classes, researchers just considered syntactic relationship between class members such as interactions between instance variables and methods. However, more recent researches have been tried to identify inherent characteristics of classes which can affect the cohesiveness of classes and incorporate them into cohesion metrics.

Bieman and Kang distinguished public methods from non-public methods and proposed LCC (Loose Class Cohesion) and TCC (Tight Class Cohesion) only with public methods in a class [3]. They also excluded constructors and destructors in order to remove the impact of artificial connection by those methods. In their comprehensive overview of object-oriented cohesion measures, Briand et al. [4] also addressed that access methods1 artificially decrease class cohesion, whereas constructors and destructors artificially increase class cohesion. In order to resolve such problems due to access methods, constructors, and destructors, Chae et al. [10] introduced the notion of special methods. They noted that special methods have no influence on class cohesion because those methods are designed to show a specific behavior, interacting inherently with only some of instance variables for the specific purposes. They also tried to improve cohesion measures by considering characteristics of dependent instance variables in a class. That is, they attempted to enhance the existing cohesion measures by including the implicit and hidden interactions between class members due to data dependency [11].

In this paper, we propose an approach to enhancing the existing cohesion measures by incorporating some characteristics that are relevant to class cohesion, but have not been considered before. In general, cohesion depends on the interactions between class members; that is, the more interactions between class members have, the more cohesive the class is. The interactions between methods and instance variables can be classified into two categories: read interactions and write interactions. We note that a write interaction should be considered stronger than a read interaction because the write interaction can affect other methods that read the instance variable written. The existing cohesion measures do not distinguish write interactions from read interactions. However, we believe that write interactions have more contribution to cohesiveness of a class than read interactions.

We present an approach to improving the existing cohesion measures by emphasizing write interactions between class members. We also demonstrate the importance of our approach by performing a case study with Java class libraries. Discussion on effects of the write interactions is centered on LCOM12 [13], LCOM2 [14], TCC [3], Co [18], and LCOM5 [22] measures because they have been used in numerous empirical studies for investigating relationship between measures and quality factors such as development/maintenance effort [1], [6], [12], [20], [19], fault-proneness [2], [8], [7], [16], [21], and testability [9]. In addition, their use is gradually increasing in industry settings. This is manifested by the increasing number of industrial software tools, such as Together Control Center, which support automated computation of LCOMs.

The basic concept discussed in this paper was proposed in the previous work[25]. This paper describes extensions in three respects.

  • In this paper, two more cohesion measures, namely Co and LCOM5, are additionally revised to consider the impact of the write interactions. In addition, we give an intuitive description on the necessity of considering write interactions using an example. Furthermore, the reducibility from new measures to the old ones is also proved.

  • We have performed a further case study. In this experiment, we computed the original and the revised cohesion values from 1183 classes of JDK. This experiment shows that write interactions are frequently used and they have much influence on cohesion measurement. In addition we performed correlation analysis with change-proneness. This experiment shows that the revised cohesion measures could be better indicators to predicting the change-proneness of classes better than the original ones.

  • To perform a case study, we have developed new tools for automating measurement of the original and the revised measures. In the previous paper, we performed a case study with C++ libraries by the tool based on GEN++ [15]. However, GEN++ fails to handle advanced C++ features such as namespace and template. Based on APIs of Together tool, the newly developed tool can handle such features. In addition, Java as well as C++ can be processed.

The rest of this paper is organized as follows: Section 2 briefly describes five existing cohesion measures. Section 3 describes a rationale for the consideration of write interactions, proposes revised versions of the existing cohesion measures, and proves that the revised versions can be reduced into the original ones. Section 4 describes a case study to show the importance of write interactions on cohesion measurement. Finally, conclusions and suggestions for the future works are given in Section 5.

Section snippets

The original cohesion measures

This section describes five cohesion measures under study in this paper. First we introduce some basic notations for the clear description of the cohesion measures and then briefly define the cohesion measures using them.

The revised cohesion measures

This section presents an approach to revising the existing cohesion measures by considering the impact of write interactions between class members. First we explain the necessity of the special consideration of the write interactions. And then we describe some basic definitions to incorporate write interactions into cohesion measures, and then present the revised version for each cohesion measure. Finally, we show that the revised versions can be reduced into the original ones.

A case study

This section describes a case study we have performed to show the importance of our revised cohesion measures compared with the original ones. Section 4.1 describes the experimental settings, including special tools developed for computing cohesion measures, a subject software, and the experiment procedures. Section 4.2 gives a summary of the experiment results and correlation analysis with change-proneness.

Conclusion and future work

In this paper we emphasized the effect of write interactions over read interactions between class members, and proposed the revised versions of LCOM1, LCOM2, LCOM5, TCC, and Co, where write interactions between class members are given more weight. Also, we explored the importance of our approach by performing a case study. In the case study, we found that write interactions were commonly used and cohesion values of many classes were significantly affected by the consideration of the write

Acknowledgements

This research was supported by the MKE (Ministry of Knowledge Economy), Korea, under the ITRC (Information Technology Research Center) support program supervised by the IITA (Institute of Information Technology Advancement: grant number IITA-2008-(C1090-0801-0032)) and the Brain Korea 21 Project in 2008.

References (25)

  • L.C. Briand et al.

    Exploring the relationship between design measures and software quality in object-oriented systems

    Journal of Systems and Software

    (2000)
  • W. Li et al.

    Object-oriented metrics that predict maintainability

    Journal of Systems and Software

    (1993)
  • M. Alshayeb et al.

    An empirical validation of object-oriented metrics in two different iterative software processes

    IEEE Transactions on Software Engineering

    (2003)
  • V.R. Basili et al.

    A validation of object-oriented design metrics as quality indicators

    IEEE Transactions on Software Engineering

    (1996)
  • J.M. Bieman, B.K. Kang, Cohesion and reuse in an object-oriented system, in: ACM SIGSOFT Symposium on Software...
  • L.C. Briand et al.

    A unified framework for cohesion measurement in object-oriented systems

    Empirical Software Engineering

    (1998)
  • L.C. Briand et al.

    A unified framework for coupling measurement in object-oriented systems

    IEEE Transactions on Software Engineering

    (1999)
  • L.C. Briand et al.

    Modeling development effort in object-oriented systems using design properties

    IEEE Transactions on Software Engineering

    (2001)
  • L.C. Briand et al.

    Investigating quality factors in object-oriented designs: an industrial case study

  • M. Bruntink and A. Deursen, Predicting class testability using object-oriented metrics, in: SCAM, 2004, pp....
  • H.S. Chae et al.

    A cohesion measure for object-oriented classes

    Software Practice and Experience

    (2000)
  • H.S. Chae et al.

    Improving cohesion metrics for classes by considering dependent instance variables

    IEEE Transactions on Software Engineering

    (2004)
  • Cited by (7)

    • Change impact analysis: A systematic mapping study

      2021, Journal of Systems and Software
    • Dynamic cohesion measures for object-oriented software

      2011, Journal of Systems Architecture
      Citation Excerpt :

      The amount of correlation between DCC and change-proneness is much higher than that of other reported cohesion metrics in Table 7. Woo et al. have already shown that the revised cohesion measures, LCOM1w, LCOM2w, and TCCw, have stronger relation with the change-proneness of classes than LCOM1, LCOM2, and TCC in [41]. The results of the correlation study conducted in this paper show that the proposed measures have got much stronger relation with change-proneness than the cohesion measures such as LCOM1w, LCOM2w, and TCCw, which suggests that the proposed measures may be better indicators than the existing measures for predicating change-proneness.

    • An empirical analysis of lack of cohesion metrics for predicting testability of classes

      2011, International Journal of Software Engineering and its Applications
    • Exploring empirically the relationship between lack of cohesion in object-oriented systems and coupling and size

      2010, ICSOFT 2010 - Proceedings of the 5th International Conference on Software and Data Technologies
    View all citing articles on Scopus
    View full text