tushartushar / DesigniteJava

Detects smells and computes metrics of Java code
https://www.designite-tools.com/products-dj
Apache License 2.0
172 stars 64 forks source link

LCOM #66

Closed luiscruz closed 5 years ago

luiscruz commented 5 years ago

Hi,

I'm having trouble to understand the Lack of Cohesion Metric (LCOM). I think I should get values between 0 and 1, but I am getting negative values in several projects:

To name a few:

Let me know if you need more data.

tushartushar commented 5 years ago

Hi, The implemented LCOM is a custom implementation to avoid the problems of existing LCOM alternatives. Traditional, LCOM value may range only between 0 and 1. However, there are many cases, when computing LCOM is not feasible and traditional implementations give value 0 giving us a false sense of satisfaction. So, when you find -1 as LCOM value for a class, this means we do not have enough information or LCOM is not applicable (for instance, for an interface) for the class/interface. More details can be found here (though, it is an old post): http://www.tusharma.in/technical/revisiting-lcom/

luiscruz commented 5 years ago

Perfect, thanks 👌

ana-roman commented 4 years ago

I am currently using Designite as part of a University project, to analyse an OSS. I came across the negative values in the LCOM column of the Type Metrics, and I was also quite confused as to what this value might represent. This answer clarified the value! And this made me think that it would maybe be a good idea to include such an explanation in the official documentation as well, to prevent further confusion and/or issues.

tushartushar commented 4 years ago

@ana-roman I agree. I will definitely do it.