Archive for the ‘Static Code Analysis’ Category

“Law of Demeter” as a Software Metric

June 3rd, 2012 Comments off

The “Law of Demeter” (LoD) is one important principle to achieve low coupling in your code. And it could be turned into a software metric easily.

To measure the coupling, you could count the “LoD violations” per method. “0” means that no violations occured and the result is increased by 1 for every violation that was found.

I am wondering if someone implemented such a metric and if it could be used in Eclipse or NetBeans.

Here is a small example.

Read more…