Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible bug with LCOM #50

Open
adilek opened this issue Nov 22, 2017 · 1 comment
Open

Possible bug with LCOM #50

adilek opened this issue Nov 22, 2017 · 1 comment

Comments

@adilek
Copy link

adilek commented Nov 22, 2017

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.

adilek added a commit to adilek/MetricsReloaded that referenced this issue Nov 22, 2017
@adilek
Copy link
Author

adilek commented Nov 23, 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant