260 likes | 478 Views
COHESION MEASUREMENTS. By Abubakar Adam (April, 2004). Outline. Introduction Cohesion metrics in the literature Classification for cohesion metrics New Metric. Introduction.
E N D
COHESION MEASUREMENTS By Abubakar Adam (April, 2004)
Outline • Introduction • Cohesion metrics in the literature • Classification for cohesion metrics • New Metric
Introduction • Cohesion determines the extent to which the individual components of a module are required to perform the same task • While cohesion addresses intra-module connectedness, coupling addresses inter-module connectedness
Introduction • A cohesive module: • Has all its components tailored towards one functionality • Does not rely on other modules • Is easy to maintain • Cohesion should be maximized • Coupling should be minimized
LCOM1 • LCOM1 is the number of pairs of methods with no common attributes references • From the example given Below, LCOM1 = 2
LCOM2 • Consider a class C with methods M1, M2,….., Mn. Let {Ii} = set of instance variables used by method Mi. There are n such sets, i.e., {1i}, {I2},….., {In}. Let P = { (Ii, Ij ) | Ii Ij = } and Q = {(Ii, Ij ) | Ii Ij }. If all n sets {1i}, {I2},….., {In} are then let P = . LCOM2 = P = 2 and Q = 1 thus LCOM2 = 1
LCOM3 • 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. • LCOM3=|connected components of G| LCOM3 = 2
LCOM4 • Like LCOM3, where graph G additionally has an edge between vertices representing methods Mi and Mj, if Mi invokes Mj or vice versa. LCOM4 = 1
The Connectivity Metric Co(C) = From the example given above, we have Ec = 2 and Vc = 3. Hence, Co(C) = 0
The TCC and LCC Metrics NP(C) = NDC(C) = 2, NIC(C) = 1 and NP(C) = 3, Thus, TCC = 2/3 and LCC = 1
The LCOM5 Metric LCOM5 = From the example, we have: m = 3 and a = 3, Thus, LCOM5 = 2/3
The RCI Metric CI means cohesive interactions = the set of all DD- and DM-interactions present in the class C Max(C) = the set of all possible DD- and DM-interactions that can be established in class C From the example we have, |CI(C)| = 8 |Max(C)| = 30 Hence, RCI = 8/30 = 4/15
The CBMC Metrc Mg = the set of glue methods Mn = the set normal methods Glue methods are the minimum number of methods without which the reference graph will be divided into sub-graphs. It is one of the n children of Gr in the structure tree; CBMC denotes the cohesion of a component .
The CCM and ECCM Metrics NORM(C) is the number of re-implemented methods and NOIM(C) is the number of inherited methods
CCM and ECCM Example NC(C) = 5, NMP(C) = 10 and NCC(C) = 1 hence CCM = 2/5 Note: ECCM = CCM because in this example no specification is given for the inherited methods
Classification for Cohesion Metrics • There are two types of classification criteria • Factor • Characteristic • Factors: these criteria identify the things that may affect the cohesiveness of a module. • Characteristics: these criteria, as the name implies, describe the characteristics of the cohesion metric i.e the features of the metric.