You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems the constructor is not considered during LCOM calculation.
Consider the following code:
public class MyClass {
int var1;
int var2;
int var3;
int var4;
public MyClass(int var1, int var2, int var3, int var4) {
this.var1 = var1;
this.var2 = var2;
this.var3 = var3;
this.var4 = var4;
}
public int getVar1() {
return var1;
}
public int getVar2() {
return var2;
}
public int getVar3() {
return var3;
}
public int getVar4() {
return var4;
}
}
MetricsReloaded will show the LCOM as 4. But actually it should be 1. If look at it as a graph they all are connected and we have only one connected component.
If we change the same code to this:
public class MyClass {
int var1;
int var2;
int var3;
int var4;
public MyClass(int var1, int var2, int var3, int var4) {
init(var1, var2, var3, var4);
}
public void init(int var1, int var2, int var3, int var4) {
this.var1 = var1;
this.var2 = var2;
this.var3 = var3;
this.var4 = var4;
}
public int getVar1() {
return var1;
}
public int getVar2() {
return var2;
}
public int getVar3() {
return var3;
}
public int getVar4() {
return var4;
}
}
Now it shows LCOM 1. The behaviour and cohesivness was not changed. But LCOM changed. This seems incorrect behaviour.
The text was updated successfully, but these errors were encountered:
adilek
added a commit
to adilek/MetricsReloaded
that referenced
this issue
Nov 22, 2017
After reader some more papers it turns out that original paper did not mention about constructors. However some tools include constructors and destructors some not.
In case of constructors need to be excluded for the original LCOM4 then it would be good to have one metrics more for LCOM with constructors.
It seems the constructor is not considered during LCOM calculation.
Consider the following code:
MetricsReloaded will show the LCOM as 4. But actually it should be 1. If look at it as a graph they all are connected and we have only one connected component.
If we change the same code to this:
Now it shows LCOM 1. The behaviour and cohesivness was not changed. But LCOM changed. This seems incorrect behaviour.
The text was updated successfully, but these errors were encountered: