Client based Object-Oriented Cohesion Metrics

  • Authors:
  • Sami Makela;Ville Leppanen

  • Affiliations:
  • University of Turku and TUCS, Finland;University of Turku and TUCS, Finland

  • Venue:
  • COMPSAC '07 Proceedings of the 31st Annual International Computer Software and Applications Conference - Volume 02
  • Year:
  • 2007

Quantified Score

Hi-index 0.00

Visualization

Abstract

For code quality control, there exists tens of objectoriented (OO) metrics on class cohesion and coupling. This abundant variety indicates that designing feasible metrics to differentiate good object-oriented programs from bad ones is not an easy task. Even worse, in practice OO cohesion metrics have a minor role in code reviews. In this paper we argue the proposed cohesion metrics, based on internal usage of class members, yield misleading (bad) values for several reasons. We propose a totally different kind of cohesion metric based on external class usage.Cohesion metrics typically define a bipartite usage graph between methods of a class and its variables. Providing different interpretations for methods, variables, usage relation, and calculation method have served as sources of variation. Classical interpretation is to measure internal usage of instance variables by the instance methods of a class to evaluate relatedness of the class properties. We argue that the relatedness also depends on the usage context, e.g. an application. Another problem is that objects often consist of property sets that are only slightly related internally, since an inheriting class often defines properties that are only slightly related to the inherited ones. Yet, the clients of such objects often make connections between the property sets by simultaneously advancing internally seemingly unrelated property sets.We propose forming cohesion graphs between the clients of a class and its member variables. Our approach complements the internal cohesion view with external views based on the external usage of class properties. We provide results for three popular open-source projects indicating our external cohesion measure to give much more meaningful results.