zoukankan      html  css  js  c++  java
  • Object-Oriented Metrics: LCOM 内聚性的度量

     

    Object-Oriented Metrics: LCOM https://www.computing.dcu.ie/~renaat/ca421/LCOM.html

    Object-Oriented Metrics: LCOM

     LCOM (Lack of Cohesion of Methods) as revised by Brian  Henderson-Sellers  in [HEN96] 


    CK originally proposed LCOM

    Chidamber  & Kemerer proposed the original LCOM Lack of Cohesion metric in [CHI94]

    Given n methods M1, M2, …, Mn  contained in a class C1 which also contains a set of instance variables {Ii} . Then for any method Mi we can define the partitioned set of 

    P = {(Ii, Ij) | Ii ∩ Ij = φ} and Q = {(Ii, Ij) | Ii ∩ Ij ≠ φ}

    then LCOM = |P| - |Q|, if |P| > |Q|

    =0 otherwise

     LCOM is a count of the number of method pairs whose similarity is zero.


    CK example from  [HEN96] LCOM as defined above

    凝集度の高いクラス凝集度の低いクラス
    Based on M's as methods and A's as instance variables both of the above graphs of classes derive an LCOM measure of   8.

    However it seems clear that the graph on the right  is a lot more intuitively cohesive. 
     

    Henderson-Sellers revised LCOM*

    Henderson-Sellers revises the LCOM metric to normalise it for the number of methods and variables that rae present in the class:

    LCOM*

    Where the number of methods is m and the number of instance variables ( attributes) a set of  {Aj}  (j=1, 2, …, a). Let μ(Aj) be the number of methods which access each datum.

    With this new measure the mteric is simplified an normalised.


    References

    [CHI94] Chidamber, S., R., Kemerer, C., K., A Metrics Suite for Object Oriented Design, IEEE Trans. on Software Eng., Vol.20, No.6, June 1994.
    [HEN 96] Henderson-Sellers, B., Object-oriented metrics : measures of complexity, Prentice-Hall, pp.142-147, 1996.

  • 相关阅读:
    封装ajax---基于axios
    XHR的理解和作用
    params和 query区别
    HTTP请求交互的基本过程
    http3次握手
    ES6----import * as 用法
    微信小程序真机调试:Setting data field "XXX" to undefined is invalid
    webpack详解-----optimization
    node跨域
    shell 的 功能语句--1
  • 原文地址:https://www.cnblogs.com/rsapaper/p/9767552.html
Copyright © 2011-2022 走看看