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.

  • 相关阅读:
    linux系统分析工具续-SystemTap和火焰图(Flame Graph)
    如何使用strace+pstack利器分析程序性能
    MySQL数据类型-decimal详解
    服务器端数据合法性验证:签名sign和口令token原理
    linux系统下php通过php_oci8扩展连接oracle数据库 Nginx
    redis开启远程访问
    cURL函数库错误码说明之PHP curl_errno函数
    权限控制相关模块
    otool
    路由器
  • 原文地址:https://www.cnblogs.com/rsapaper/p/9767552.html
Copyright © 2011-2022 走看看