Skip to main content

Relationship Between Cohesion and Coupling Metrics for Object-Oriented Systems

  • Conference paper
  • First Online:

Part of the book series: Communications in Computer and Information Science ((CCIS,volume 920))

Abstract

Cohesion and coupling are regarded as fundamental features of the internal quality of object-oriented systems (OOS). Analyzing the relationships between cohesion and coupling metrics plays a significant role to develop efficient techniques for determining the external quality of an object-oriented system. Researchers have proposed several metrics to find cohesion and coupling in object-oriented systems. However, few of them have proposed an analysis of the relationship between cohesion and coupling. This paper empirically investigates the relationships among several cohesion and coupling metrics in object-oriented systems. This work attempts to find mutual relationships between those metrics by statistically analyzing the results of experiments. Three open-source Java systems were used for experimentation. The empirical study shows that cohesion and coupling metrics are inversely correlated.

Supported by organization x.

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

References

  1. Al Dallal, J.: Fault prediction and the discriminative powers of connectivity-based object-oriented class cohesion metrics. Inf. Softw. Technol. 54(4), 396–416 (2012)

    Article  Google Scholar 

  2. Al Dallal, J.: Empirical analysis of the relation between object-oriented class lack-of-cohesion and coupling. AWERProcedia Inf. Technol. Comput. Sci. 4, 34–39 (2013)

    Google Scholar 

  3. Al Dallal, J.: Empirical exploration for the correlation between class object-oriented connectivity-based cohesion and coupling. Int. J. Comput. Electr. Autom. Control Inf. Eng. 9(4), 934–937 (2015)

    Google Scholar 

  4. Al Dallal, J., Briand, L.C.: A precise method-method interaction-based cohesion metric for object-oriented classes. ACM Trans. Softw. Eng. Methodol. (TOSEM) 21(2), 8 (2012)

    Article  Google Scholar 

  5. Anabalon, D., Flores, A., Mateos, C., Zunino, A., Misra, S.: Controlling complexity of web services interfaces through a metrics-driven approach. In: 2017 International Conference on Computing Networking and Informatics (ICCNI), pp. 1–9. IEEE (2017)

    Google Scholar 

  6. Apiwattanapong, T., Orso, A., Harrold, M.J.: Efficient and precise dynamic impact analysis using execute-after sequences. In: Proceedings of the 27th International Conference on Software Engineering, pp. 432–441. ACM (2005)

    Google Scholar 

  7. Arisholm, E.: Dynamic coupling measures for object-oriented software. In: Proceedings of the 8th International Symposium on Software Metrics, METRICS 2002, p. 33. IEEE Computer Society, Washington, DC (2002). http://dl.acm.org/citation.cfm?id=823457.824024

  8. Arisholm, E., Briand, L.C., Foyen, A.: Dynamic coupling measurement for object-oriented software. IEEE Trans. Softw. Eng. 30(8), 491–506 (2004). https://doi.org/10.1109/TSE.2004.41

    Article  Google Scholar 

  9. Badri, L., Badri, M., Gueye, A.B.: Revisiting class cohesion: an empirical investigation on several systems. J. Object Technol. 7(6), 55–75 (2008)

    Article  Google Scholar 

  10. Bieman, J.M., Kang, B.K.: Cohesion and reuse in an object-oriented system. In: ACM SIGSOFT Software Engineering Notes, vol. 20, pp. 259–262. ACM (1995)

    Article  Google Scholar 

  11. Bieman, J.M., Ott, L.M.: Measuring functional cohesion. IEEE Trans. Softw. Eng. 20(8), 644–657 (1994)

    Article  Google Scholar 

  12. Bonja, C., Kidanmariam, E.: Metrics for class cohesion and similarity between methods. In: Proceedings of the 44th Annual Southeast Regional Conference, pp. 91–95. ACM (2006)

    Google Scholar 

  13. Briand, L., Devanbu, P., Melo, W.: An investigation into coupling measures for C++. In: Proceedings of the 19th International Conference on Software Engineering, pp. 412–421. ACM (1997)

    Google Scholar 

  14. Briand, L., Morasca, S., Basili, V.R.: Defining and validating high-level design metrics (1994)

    Google Scholar 

  15. Chae, H.S., Kwon, Y.R., Bae, D.H.: A cohesion measure for object-oriented classes. Softw.-Pract. Experience 30(12), 1405–1432 (2000)

    Article  Google Scholar 

  16. Chidamber, S.R., Kemerer, C.F.: Towards a metrics suite for object oriented design, vol. 26. ACM (1991)

    Google Scholar 

  17. Chidamber, S.R., Kemerer, C.F.: A metrics suite for object oriented design. IEEE Trans. Softw. Eng. 20(6), 476–493 (1994)

    Article  Google Scholar 

  18. Fernández, L., Peña, R.: A sensitive metric of class cohesion (2006)

    Google Scholar 

  19. Gupta, V.: Validation of dynamic coupling metrics for object-oriented software. ACM SIGSOFT Softw. Eng. Notes 36(5), 1–3 (2011)

    Article  MathSciNet  Google Scholar 

  20. Gupta, V., Chhabra, J.K.: Object level run-time cohesion measurement. In: Information Theories & Applications, p. 136 (1993)

    Google Scholar 

  21. Gupta, V., Chhabra, J.K.: Package level cohesion measurement in object-oriented software. J. Braz. Comput. Soc. 18(3), 251–266 (2012)

    Article  Google Scholar 

  22. Henderson-Sellers, B.: Software metrics (1996)

    Google Scholar 

  23. Hitz, M., Montazeri, B.: Measuring coupling and cohesion in object-oriented systems (1995)

    Google Scholar 

  24. Kabaili, H., Keller, R., Lustman, F.: Class cohesion as predictor of changeability: An empirical study (2001)

    Google Scholar 

  25. Kumar, L., Misra, S., Rath, S.K.: An empirical analysis of the effectiveness of software metrics and fault prediction model for identifying faulty classes. Comput. Stand. Interfaces 53, 1–32 (2017)

    Article  Google Scholar 

  26. Li, W., Henry, S.: Maintenance metrics for the object oriented paradigm. In: First International Software Metrics Symposium, Proceedings, pp. 52–60. IEEE (1993)

    Google Scholar 

  27. Li, W., Henry, S.: Object-oriented metrics that predict maintainability. J. Syst. Softw. 23(2), 111–122 (1993)

    Article  Google Scholar 

  28. Mateos, C., Zunino, A., Misra, S., Anabalon, D., Flores, A.: Keeping web service interface complexity low using an oo metric-based early approach. In: 2016 XLII Latin American Computing Conference (CLEI), pp. 1–12. IEEE (2016)

    Google Scholar 

  29. Misic, V.B.: Cohesion is structural, coherence is functional: different views, different measures. In: Seventh International Software Metrics Symposium, METRICS 2001, Proceedings, pp. 135–144. IEEE (2001)

    Google Scholar 

  30. Mitchell, Á., Power, J.F.: An empirical investigation into the dimensions of run-time coupling in java programs. In: Proceedings of the 3rd International Symposium on Principles and Practice of Programming in Java, pp. 9–14. Trinity College Dublin (2004)

    Google Scholar 

  31. Morris, K.L.: Metrics for object-oriented software development environments. Ph.D. thesis, Massachusetts Institute of Technology (1989)

    Google Scholar 

  32. Rathore, S.S., Gupta, A.: Investigating object-oriented design metrics to predict fault-proneness of software modules. In: 2012 CSI Sixth International Conference on Software Engineering (CONSEG), pp. 1–10. IEEE (2012)

    Google Scholar 

  33. Xu, B., Zhou, Y.: Comments on ‘a cohesion measure for object-oriented classes’ by heung seok chae, yong rae kwon and doo hwan bae (Softw. Pract. Exper. 30, 1405–1431 (2000)). Softw. Pract. Exper. 31(14), 1381–1388 (2001)

    Google Scholar 

  34. Yang, X.: Research on cohesion measures for classes. Ph.D. thesis, Master Thesis, Department of Computer Science & Engineering in Southeast University (2002)

    Google Scholar 

Download references

Acknowledgement

We thank Professor Jehad Al Dallal of Kuwait University, for the authorization given to make use of the tool (Quality Measuring Tool) developed by him.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Samuel António Miquirice .

Editor information

Editors and Affiliations

Appendices

Appendix

A Definitions of Cohesion Metrics:

figure a

LCOM1, (Lack of Cohesion in Methods 1), [16].

The number of pairs of methods in the class using no instance variables in common.

figure b

LCOM2, (Lack of Cohesion in Methods 2), [17].

$$\begin{aligned} LCOM2= \left\{ \begin{array}{cl} P-Q, &{} if \; P-Q \ge 0 \\ 0, &{} otherwise \\ \end{array} \right. \end{aligned}$$

where, P = number of pairs of methods without shared instance variables. Q = number of pair of methods with shared instance variables.

figure c

LCOM3, (Lack of Cohesion in Methods 3), [26].

Consider an undirected graph G, where the vertices are the methods of a class, and there is an edge between two vertices if the corresponding methods share at least one instance variable. Then \(LCOM3=|connected \ components \ of \ G|\).

figure d

LCOM4, (Lack of Cohesion in Methods 4), [23].

LCOM4 is similar to LCOM3, where graph G additionally has an edge between vertices representing methods \(M_i\) and \(M_j\), if \(M_i\) invokes \(M_j\) or vice versa.

figure e

LCOM5, (Lack of Cohesion in Methods 5), [22].

Consider a set of methods \( \{M_i \}(i=1...m)\) accessing a set of instance variables \(\{A_j \}(j=1...a)\). Let \(\mu (A_j )\) be the number of methods that reference \(A_j\). Then \(LCOM5= \frac{\frac{1}{a}\times \sum _{1\le j\le a}\,\times \,\mu (A_j)-m}{1-m} \).

figure f

CBMC, (Cohesion Based on Member Connectivity), [15].

The CBMC for a class C, CBMC(C), is defined to be the connectivity factor of its reference graph, \(F_c (G_r (C))\), scaled by the structure factor of its reference graph, \(F_s (G_r (C) )\). \(CBMC(C)=F_c (G_r (C) )\times F_s (G_r (C) )=F_c (G_r (C) )\times \frac{1}{n} \sum _{i=1}^n CBMC({G_r}^i (C) ) \) The connectivity factor of a reference graph \(G_r, F_c (G_r)\), represents the degree of the connectivity among the members, and is defined to be the ratio of the number of glue methods \(|M_g (G_r)|\) to the number of normal methods \(|M_n (G_r)|\): \(F_c (G_r)= \frac{|M_g (G_r)|}{|M_n (G_r)|}\).

The structure factor for a reference graph \(G_r, F_s (G_r )\), is defined to be the average cohesion of its children in the structure tree: \(F_s (G_r )\) = \(\frac{1}{n}\times \sum _{i=1}^n CBMC({G_r}^i )\) where \({G_r}^i\) is one of the n children of \(G_r\) in the structure tree, and \(CBMC({G_r}^i )\) denotes the cohesion of a component \({G_r}^i\).

figure g

ICBMC, (Improved Cohesion Based on Member Connectivity), [33].

The cohesion for the reference graph \(G_c = (N_c, E_c)\) of a class c is defined: \(ICBMC(G_c )=\)

$$\begin{aligned} \left\{ \begin{array}{cl} \frac{|M_g |}{|N_m (G(c))|\times |N_v (G(c))|}\times \frac{1}{2} \times \sum \nolimits _{i=1}^{2} ICBMC(G_{M_g}^i ) \, \mid \; Q \in CS(G), \end{array} \right\} \end{aligned}$$
(1)

where \(N_m\) and \(N_v\) denote the set of vertexes representing methods and the set of vertexes representing instance variables of class c, respectively; G is called an elementary component of \(G_c\). If a graph \(G' =(N',V')\) is a sub graph of the reference graph \(G_c\) and its non-spanning graphs contain elementary components, then \(G'\) is called a non-elementary component of \(G_c\). \(G_c = (N_c, E_c)\) is the reference graph of a class c. Q is the minimum set of edges.

figure h

\(OL_n\), [34].

This metric can be defined as the common strength of attributes. The strength of the attribute can be defined as the common strength of the methods that approach that attribute. Where n are the numbers of iteration which are used to calculate OL. COM(m) and COV(v) are used to represent the strength of method m and instance variable v respectively in Yang’s cohesion measure. For a given class c, Yang first constructs a corresponding reference graph \(G_c\). If \(G_c\) is disjoint, then let its cohesion be 0, otherwise computes its cohesion value by the following steps: (1) Initialize the iteration count variable count to 0, i.e., let count = 0; (2) For every method \(m_i\), set its initial strength to 1, i.e., let \(COM (m_i) = 1\); (3) For every instance variable \(v_i\), let \(COV(v_i)=\frac{1}{N_m (G_c)} \times \sum _{j=1}^{l} COM (m_j)\) where \(N_m (G_c)\) denotes the number of method vertexes in \(G_c\) and \(\lambda (m_j,c)\); (4) For every method \(m_i\), let \(COM(m_i)=\frac{1}{N_v (G_c)} \times \sum _{k=1}^{m} COM (v_k)\), where \(N_v (G_c)\) denotes the number of instance variable vertices in \(G_c\) and \(v_{k \in \lambda (m_j,c)}\); (5) \(count = count + 1\), if \(count <n\) then Go to (3) (6) Compute the cohesion of class c, i.e., let \(OL_n (c)\)=\(\frac{1}{N_v (G)} \times \sum _{r=1}^{N_v (G)}COV (v_r)\).

figure i

PCCC, (Path Connectivity Class Cohesion), [1].

$$\begin{aligned} PCCC(C)= \left\{ \begin{array}{cl} 0, &{} if \; l=0 \; and \; k>1 \\ 1, &{} if \; l>0 \; and \; k=1 \\ \frac{NSP(G_c)}{NSP(FG_c)}, &{} otherwise \\ \end{array} \right. \end{aligned}$$

Where l is the number of attributes, k is the number of methods and NSP is the number of simple paths in graph \(G_c\); \(FG_c=\) corresponding fully connected graph.

figure j

LSCC, (Low-level design Similarity-based Class Cohesion), [4].

$$\begin{aligned} LSCC(C)= \left\{ \begin{array}{cl} 0, &{} if \; k=0 \; or \; l=0 \\ 1, &{} if \; k=1 \\ \frac{\sum _{i=1}^{l} x_i (x_i-1)}{lk(k-1)}, &{} otherwise \\ \end{array} \right. \end{aligned}$$

Where l is the number of attributes, k is the number of methods and \(x_i\) is the number of methods that referenced.

figure k

CC, (Class Cohesion), [12].

CC = Ratio of the summation of the similarities between all pairs of methods to the total number of pairs of methods. The similarity between methods i and j are defined as: \(Similarity (i,j) =\frac{|I_i \cap I_j |}{|I_i \cup I_j |}\) where \(I_i\) and \(I_j\) are the sets of attributes referenced by methods i and j, respectively.

figure l

SCOM, (Sensitive Class Cohesion Metric), [18].

SCOM = Ratio of the summation of the similarities between all pairs of methods to the total number of pairs of methods. The similarity between methods i and j is defined as: \(Similarity (i,j)=\frac{|I_i \cap I_j |}{(|I_i |,|I_j|)}\times \frac{|I_i \cup I_j |}{l}\), where l is the number of attributes.

figure m

TCC, (Tight Class Cohesion), [10].

Consider a class with N public methods. Let NP be the maximum number of public method pairs: \(NP=[N \times (N-1)]/2\). Let NDC be the number of direct connections between public methods. Then TCC is defined as the relative number of directly connected public methods. Then, \(TCC=NDC/NP\).

figure n

LCC, (Loose Class Cohesion), [10].

Consider a class with N public methods. Let NP be the maximum number of public method pairs: \(NP=[N \times (N-1)]/2\). Let NIC be the number of direct or indirect connections between public methods. Then LCC is defined as the relative number of directly or indirectly connected public methods. \(LCC=NIC/NP\).

figure o

B Definitions of Cohesion Metrics:

figure p

CBO_IUB, (CBO Is Used By), [24].

(CBO Is Used By: the part of CBO that consists of the classes using the target class): the definition of CBO merges two coupling directions: classes using the target class and classes used by the class. For changeability purposes, the former seems more relevant than the latter one, hence the split.

figure q

CBO_U, (CBO Using), [24].

(CBO Using: the part of CBO that consists of the classes used by the target class): introduced as a consequence of CBO_IUB, to cover the part of CBO not considered by CBO_IUB.

figure r

CBO, (Coupling between Object Classes), [16].

CBO for a class is the count of the number of other classes to which it is coupled. A class is coupled with another class if the method declared in one class uses method or instance variable defined by another class. CBO includes inheritance-based coupling (i.e. coupling between classes related via inheritance). For good software quality, high CBO is undesirable.

figure s

RFC, (Response for a Class), [16].

RFC can be defined as the set of methods that can potentially be executed in response to a message received by an object of that class. \(RFC = |RS|\) where, RS = the response set for the class. The response set for the class can be defined as: \(RS = \{M_i \} \bigcup _{all \, n} \{R_i\}\) where, \(\{R_i\}\) is set of methods called by method \(M_i\) and \(\{M_i\}\) is set of all methods in the class. RFC of class A = Number of methods in class A + Number of distinct methods of other classes directly invoked by the methods of class A.

figure t

MPC, (Message Passing Coupling), [27].

The MPC metric gives an indication of how many messages are passed among objects of the classes: MPC = number of sent statements defined in a class. The number of messages sent out from a class may indicate how dependent the implementation of the local methods is on the methods in other classes. This may not be indicative of the number of messages received by the class.

figure u

DAC, (Data Abstraction Coupling), [27].

DAC or DAC1 is the number of attributes whose types are of other classes. DAC = number of ADTs (abstract data type) defined in a class. The number of variables having an ADT type may indicate the number of data structures dependent on the definitions of other classes. The more ADTs a class has, the more complex the coupling of that class with other classes. The goal in designing individual software components is to represent a concept in what will eventually be an executable form. The Abstract Data Type (ADT) is the object-based paradigm’s technique for capturing this conceptual information.

figure v

DAC2, (Data Abstraction Coupling 2), [27].

DAC2 is the number of distinct classes used as types of the attributes of the class.

figure w

OCMEC, (Cohesion Based on Member Connectivity), [13].

OCMEC is a number of distinct classes used as types of the parameters of the methods in the class.

figure x

Rights and permissions

Reprints and permissions

Copyright information

© 2018 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Miquirice, S.A., Wazlawick, R.S. (2018). Relationship Between Cohesion and Coupling Metrics for Object-Oriented Systems. In: Damaševičius, R., Vasiljevienė, G. (eds) Information and Software Technologies. ICIST 2018. Communications in Computer and Information Science, vol 920. Springer, Cham. https://doi.org/10.1007/978-3-319-99972-2_35

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-99972-2_35

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-99971-5

  • Online ISBN: 978-3-319-99972-2

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics