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

Definition of LCOM metric used-please specify and rules to detect implementation smells #70

Closed sac111 closed 5 years ago

sac111 commented 5 years ago

I am sorry to say I could not find which definition of LCOM is being used here . I would request to please specify how LCOM here is calculated.

Also I am not able to find rules to detect various implementation smells - can you please specify...

Thanks.

Thodoras commented 5 years ago

An informal Definition of LCOM that we use is the following: we divide the properties of a class into connected components. Connected components contain properties of the class that are method-connected. Two properties are method connected iff if there exists a method that accesses these two methods or it calls other methods that at some point access these two methods or a combination of the above.

Finally we compute lcom like this: If all properties live in a single connected component then lcom is 0 otherwise is calculated: number of connected components with more than one elements / number of methods in the class.

This I hope answers to your first question....

On Fri, May 24, 2019, 07:41 sac111 notifications@github.com wrote:

I am sorry to say I could not find which definition of LCOM is being used here . I would request to please specify how LCOM here is calculated.

Also I am not able to find rules to detect various implementation smells - can you please specify...

Thanks.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/tushartushar/DesigniteJava/issues/70?email_source=notifications&email_token=ACV4VIFQZEB2FCQCCEJHX23PW5WXJA5CNFSM4HPMENQ2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GVTSNAQ, or mute the thread https://github.com/notifications/unsubscribe-auth/ACV4VIE2K4YNDAINJS2P4Y3PW5WXJANCNFSM4HPMENQQ .

sac111 commented 5 years ago

Thanks for reply.. According to definition... low value of LCOM is preferable... I am right??....

Thodoras commented 5 years ago

Yes, 0 is totally cohesive. Worst case scenario is that you'll have each property corresponding to one method then the ratio above will be equal to 1. So yes the lower the lcom value is the most cohesive your class will be...

On Sun, May 26, 2019, 10:08 sac111 notifications@github.com wrote:

Thanks for reply.. According to definition... low value of LCOM is preferable... I am right??....

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/tushartushar/DesigniteJava/issues/70?email_source=notifications&email_token=ACV4VIFU5BGA6WJFXGPHCMTPXIZPRA5CNFSM4HPMENQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWH7Y4A#issuecomment-495975536, or mute the thread https://github.com/notifications/unsubscribe-auth/ACV4VIAWUMHOGEOOP2NOM6DPXIZPRANCNFSM4HPMENQQ .

sac111 commented 5 years ago

Right sir.. I guess that the informal definition of LCOM used here is quite close to TCC which is calculated as NP = N * (N-1) / 2 where N is the number of methods NDC = number of direct connections (number of edges in the connection graph) Tight class cohesion (TCC) = NDC/NP

So what is your comment on it...

Also please clarify on the 2nd question given below...

I am not able to find rules to detect various implementation smells - can you please specify...

tushartushar commented 5 years ago

Regarding your first question, please take a look at this post. It might give you more clarity.

The rules to detect various implementation smells are only documented within the source code. You may explore the source code and let us know if something specific needs more clarification. Even better, you may contribute back to the project by creating the same :)

sac111 commented 5 years ago

okay...

I got your point...

mehrotrasan16 commented 4 years ago

I have used DesigniteJava to analyze an open source project(PDFsam) for a class project, and some of the LCOM values are -1. Could you please explain how this is calculated? typeMetrics.xlsx

tushartushar commented 4 years ago

@mehrotrasan16 The discussion on this issue elaborates the rationale. Please go through it. Also look at this post.