November 20, 2008, 06:21:02 pm *
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Code Metrics  (Read 1460 times)
abailly
Newbie
*
Posts: 7


« on: July 27, 2007, 12:28:25 pm »

Hello,
I am a bit puzzled about the code metrics implemented in semmlecode. I am comparing what is found through semmlecode with what is found through other tools:
Here is what I find for some packages I am analyzing using JDepend (http://www.clarkware.com):
Package   TC   N   Abs   Ca   Ce   A   I   D   V
com.onyme.vdb   1   1   0   0   21   0.0%   100.0%   0.0%   1
com.onyme.vdb.commons   15   14   1   11   14   7.0%   56.0%   37.0%   1
com.onyme.vdb.direction   6   6   0   0   12   0.0%   100.0%   0.0%   1
com.onyme.vdb.engine   3   2   1   3   6   33.0%   67.0%   0.0%   1
com.onyme.vdb.regie   31   31   0   3   20   0.0%   87.0%   13.0%   1
com.onyme.vdb.regie.fusion   1   1   0   0   13   0.0%   100.0%   0.0%   1
com.onyme.vdb.regie.keys   1   1   0   0   8   0.0%   100.0%   0.0%   1
com.onyme.vdb.regie.report   2   2   0   0   17   0.0%   100.0%   0.0%   1
com.onyme.vdb.screen   5   5   0   1   12   0.0%   92.0%   8.0%   1
com.onyme.vdb.seminaire   5   5   0   13   8   0.0%   38.0%   62.0%   1
com.onyme.vdb.seminaire.question   7   6   1   11   5   14.0%   31.0%   54.000004%   1
com.onyme.vdb.seminaire.reponse   9   8   1   12   8   11.0%   40.0%   49.0%   1
com.onyme.vdb.seminaire.synthese   14   13   1   6   32   7.0%   84.0%   9.0%   1
com.onyme.vdb.tables   13   12   1   0   11   8.0%   100.0%   8.0%   1
com.onyme.vdb.tests   4   4   0   0   21   0.0%   100.0%   0.0%   1
com.onyme.vdb.xmlconverters   7   7   0   2   12   0.0%   86.0%   14.0%   1

Here is what I find using .QL queries:
Package || N || Ca || Ce || H || R || I || A || D
com.onyme.vdb | 1 | 0 | 1 | 2.0 | 1.0 | 1.0 | 0.0 | 0.0
com.onyme.vdb.commons | 15 | 50 | 15 | 2.0 | 15.0 | 0.23 | 0.06 | 0.70
com.onyme.vdb.direction | 6 | 0 | 6 | 2.16 | 7.0 | 1.0 | 0.0 | 0.0
com.onyme.vdb.engine | 3 | 4 | 3 | 2.33 | 4.0 | 0.42 | 0.0 | 0.57
com.onyme.vdb.regie | 31 | 3 | 31 | 2.41 | 44.0 | 0.91 | 0.0 | 0.08
com.onyme.vdb.regie.fusion | 1 | 0 | 1 | 2.0 | 1.0 | 1.0 | 0.0 | 0.0
com.onyme.vdb.regie.keys | 1 | 0 | 1 | 2.0 | 1.0 | 1.0 | 0.0 | 0.0
com.onyme.vdb.regie.report | 2 | 0 | 2 | 2.0 | 2.0 | 1.0 | 0.0 | 0.0
com.onyme.vdb.screen | 5 | 1 | 5 | 2.2 | 6.0 | 0.83 | 0.0 | 0.16
com.onyme.vdb.seminaire | 5 | 70 | 5 | 3.2 | 11.0 | 0.06 | 0.0 | 0.93
com.onyme.vdb.seminaire.question | 7 | 44 | 7 | 2.71 | 12.0 | 0.13 | 0.14 | 0.71
com.onyme.vdb.seminaire.reponse | 9 | 32 | 9 | 3.33 | 21.0 | 0.21 | 0.11 | 0.66
com.onyme.vdb.seminaire.synthese | 14 | 6 | 14 | 3.42 | 34.0 | 0.7 | 0.07 | 0.22
com.onyme.vdb.tables | 13 | 0 | 13 | 2.61 | 21.0 | 1.0 | 0.07 | 0.07
com.onyme.vdb.tests | 4 | 0 | 4 | 2.0 | 4.0 | 1.0 | 0.0 | 0.0
com.onyme.vdb.xmlconverters | 7 | 2 | 7 | 2.14 | 8.0 | 0.77 | 0.0 | 0.22

Do someone knows where the discrepancy is coming from ?

Regards,

Arnaud Bailly
Logged
Oege de Moor
Newbie
*
Posts: 30


« Reply #1 on: July 27, 2007, 09:47:13 pm »

Hi Arnaud,

Comparing results from different tools is an interesting thing to do. While writing the metrics definitions, we did some of that as a sanity check. However, there are many subtleties, even in seemingly simple things like "afferent coupling of a package". Most tools will not tell you what it means for one type to "depend" on another. Yet it is by no means trivial to come up with a sensible definition.

For that particular notion, some of the design decisions are documented at

http://semmle.com/content/view/216/180/ 

When we were comparing our metrics results against other tools, it was rather frustrating that they do not tell you what the definitions are. One tool we compared quite closely against was ckjm:

http://www.spinellis.gr/sw/ckjm/

That is very nicely written, and well-documented, but we felt that our definitions are more accurate - for instance it ignores generics.

The beauty of .QL is that its definitions are given explicitly, as crystal-clear declarative specifications. So, if you feel that a particular result of SemmleCode is wrong, we can debate the corresponding definition, and modify it so that it fits the intention better.

I'm afraid I don't know the meaning of the variables in your table - are there differences that look particularly suspicious?

-Oege
Logged
abailly
Newbie
*
Posts: 7


« Reply #2 on: July 28, 2007, 05:42:49 am »

Hello,
Thank you for the pointer to spinellis' tool. I did not know that one. As for the meaning, these are the metrics defined in Rob.Martin's 'Agile SOftware Development'. Sorry not having been more explicit about that Sad.
I = instability
D = distance from main sequence
A = absbtractness
V = volatility (?)
TC = total classes
N = number of concrete classe
Abs = Nb of abstract classes

And yes, I too find frustrating that some definitions aren't always given more precisely, which is presently the case. I do not have the courage to delve into JDepend to understand how their metrics are calculated.

And I like too the clear understanding .QL provides of metrics. BTW, I also did some comparisons with metrics (http://metrics.sourceforge.net/) and found the results to be closer to yours. Given time, I will try some more comparisons, just for gaining deeper understanding of those metrics. As you said in your talk at GTTSE, I too wasn't very convinced but trying to put them at use on a real project forced to try understand better their meaning which is not as fuzzzy as it may seem.

Regards,

Arnaud Bailly
Logged
Pages: [1]
  Print  
 
Jump to: