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
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsReferences
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)
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)
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)
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)
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)
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)
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
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
Badri, L., Badri, M., Gueye, A.B.: Revisiting class cohesion: an empirical investigation on several systems. J. Object Technol. 7(6), 55–75 (2008)
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)
Bieman, J.M., Ott, L.M.: Measuring functional cohesion. IEEE Trans. Softw. Eng. 20(8), 644–657 (1994)
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)
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)
Briand, L., Morasca, S., Basili, V.R.: Defining and validating high-level design metrics (1994)
Chae, H.S., Kwon, Y.R., Bae, D.H.: A cohesion measure for object-oriented classes. Softw.-Pract. Experience 30(12), 1405–1432 (2000)
Chidamber, S.R., Kemerer, C.F.: Towards a metrics suite for object oriented design, vol. 26. ACM (1991)
Chidamber, S.R., Kemerer, C.F.: A metrics suite for object oriented design. IEEE Trans. Softw. Eng. 20(6), 476–493 (1994)
Fernández, L., Peña, R.: A sensitive metric of class cohesion (2006)
Gupta, V.: Validation of dynamic coupling metrics for object-oriented software. ACM SIGSOFT Softw. Eng. Notes 36(5), 1–3 (2011)
Gupta, V., Chhabra, J.K.: Object level run-time cohesion measurement. In: Information Theories & Applications, p. 136 (1993)
Gupta, V., Chhabra, J.K.: Package level cohesion measurement in object-oriented software. J. Braz. Comput. Soc. 18(3), 251–266 (2012)
Henderson-Sellers, B.: Software metrics (1996)
Hitz, M., Montazeri, B.: Measuring coupling and cohesion in object-oriented systems (1995)
Kabaili, H., Keller, R., Lustman, F.: Class cohesion as predictor of changeability: An empirical study (2001)
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)
Li, W., Henry, S.: Maintenance metrics for the object oriented paradigm. In: First International Software Metrics Symposium, Proceedings, pp. 52–60. IEEE (1993)
Li, W., Henry, S.: Object-oriented metrics that predict maintainability. J. Syst. Softw. 23(2), 111–122 (1993)
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)
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)
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)
Morris, K.L.: Metrics for object-oriented software development environments. Ph.D. thesis, Massachusetts Institute of Technology (1989)
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)
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)
Yang, X.: Research on cohesion measures for classes. Ph.D. thesis, Master Thesis, Department of Computer Science & Engineering in Southeast University (2002)
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
Corresponding author
Editor information
Editors and Affiliations
Appendices
Appendix
A Definitions of Cohesion Metrics:
LCOM1, (Lack of Cohesion in Methods 1), [16].
The number of pairs of methods in the class using no instance variables in common.
LCOM2, (Lack of Cohesion in Methods 2), [17].
where, P = number of pairs of methods without shared instance variables. Q = number of pair of methods with shared instance variables.
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|\).
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.
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} \).
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\).
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 )=\)
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.
\(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)\).
PCCC, (Path Connectivity Class Cohesion), [1].
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.
LSCC, (Low-level design Similarity-based Class Cohesion), [4].
Where l is the number of attributes, k is the number of methods and \(x_i\) is the number of methods that referenced.
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.
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.
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\).
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\).
B Definitions of Cohesion Metrics:
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.
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.
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.
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.
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.
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.
DAC2, (Data Abstraction Coupling 2), [27].
DAC2 is the number of distinct classes used as types of the attributes of the class.
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.
Rights and permissions
Copyright information
© 2018 Springer Nature Switzerland AG
About this paper
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)