1 / 25

COHESION MEASUREMENTS

COHESION MEASUREMENTS. By Abubakar Adam (April, 2004). Outline. Introduction Cohesion metrics in the literature Classification for cohesion metrics New Metric. Introduction.

rosie
Télécharger la présentation

COHESION MEASUREMENTS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. COHESION MEASUREMENTS By Abubakar Adam (April, 2004)

  2. Outline • Introduction • Cohesion metrics in the literature • Classification for cohesion metrics • New Metric

  3. 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

  4. Introduction (Cont..)

  5. 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

  6. Cohesion metrics

  7. LCOM1 • LCOM1 is the number of pairs of methods with no common attributes references • From the example given Below, LCOM1 = 2

  8. 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

  9. 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

  10. 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

  11. The Connectivity Metric Co(C) = From the example given above, we have Ec = 2 and Vc = 3. Hence, Co(C) = 0

  12. The TCC and LCC Metrics NP(C) = NDC(C) = 2, NIC(C) = 1 and NP(C) = 3, Thus, TCC = 2/3 and LCC = 1

  13. The LCOM5 Metric LCOM5 = From the example, we have: m = 3 and a = 3, Thus, LCOM5 = 2/3

  14. 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

  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 .

  16. Example of CBMC

  17. Example of CBMC (Cont..)

  18. The CCM and ECCM Metrics NORM(C) is the number of re-implemented methods and NOIM(C) is the number of inherited methods

  19. 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

  20. The OCC and PCC

  21. General Examples

  22. 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.

  23. Classification (Cont..)

  24. Evaluating The LCOM1 Metrics

More Related