标签: lcom

为什么缺乏方法的凝聚力(LCOM)包括Getters和Setter

我正在查看此处显示的LCOM指标,

http://www.ndepend.com/Metrics.aspx

所以我们说了几件事,

1) A class is utterly cohesive if all its methods use all its instance fields
2) Both static and instance methods are counted, it includes also constructors, properties getters/setters, events add/remove methods
Run Code Online (Sandbox Code Playgroud)

如果我看一下这样的课,

public class Assessment
{
    public int StartMetres { get; set; }
    public int EndMetres { get; set; }
    public decimal? NumericResponse { get; set; }
    public string FreeResponse { get; set; }
    public string Responsetype { get; set; }
    public string ItemResponseDescription { get; …
Run Code Online (Sandbox Code Playgroud)

.net c# ndepend lcom

20
推荐指数
1
解决办法
7584
查看次数

LCOM4询问有关计算的方法

最近,我在计算LCOM4的过程中遇到了一个问题,这个度量用于查找类的方法和属性是如何隐藏的.

介绍

LCOM4是"计算方法凝聚力缺乏的第四种方法",Hitz和Montazeri对此进行了描述(http://www.isys.uni-klu.ac.at/PDF/1995-0043-MHBM.pdf)并且目前是定义一个班级拥有多少责任的最佳方式.

我会尝试不使用特定的开发语言,因为我的问题是针对所有OOP语言.

让我基本上用默认算法解释它对不知道的人的作用:

Class Foo {
    property a,b

    function f1() { this.a = 1 }
    function f2() { this.f1() }
    function f3() { this.b = 3 }
}
Run Code Online (Sandbox Code Playgroud)

这个类有两个流程:

  • 属性a由f1()和f2()共享
  • 属性b由f3()共享

所以Foo的LCOM4是2.

让我们改变例如函数f2()来共享属性b.

Class Foo {
    property a,b

    function f1() { this.a = 1 }
    function f2() { this.f1(); this.b = 1 }
    function f3() { this.b = 3 }
}
Run Code Online (Sandbox Code Playgroud)

现在这个类只有一个流程:

  • 属性a和b都由f1(),f2()和f3()共享.

这意味着Foo的LCOM4现在为1.

LCOM4 = 0或LCOM4 = 1表示班里有没有或只有1名责任,这是每个人都必须要为自己的班级,因为他们尊重小号小号奥利德良好做法.

您可以在此处找到有关图表的更多信息:http: …

oop algorithm metrics code-metrics lcom

9
推荐指数
1
解决办法
814
查看次数

如何在SonarQube 4.2中获得LCOM(缺乏方法的内聚)度量标准?

SonarQube 4.2版本是否提供LCOM指标?

我需要在我的报告中添加此指标,但我看不到它可用.

请告诉我是否有任何特定的jar来添加此指标.该指标可在Sonar 3.7中找到

任何帮助表示赞赏.

谢谢,Sreekanth

java lcom sonarqube

4
推荐指数
1
解决办法
2634
查看次数

标签 统计

lcom ×3

.net ×1

algorithm ×1

c# ×1

code-metrics ×1

java ×1

metrics ×1

ndepend ×1

oop ×1

sonarqube ×1