On 12/09/2017 11:58, Stéphane Ducasse wrote:
Hi
for certain metrics we need to compute the total amount of lines of
code for the complete project.
FAMIXClass >> calculateARLCOMUnderstand
"Class LCOM LOC
C1 12 1000
C2 2 50
For C1 1000/1050 * 12
For C2 50/1050 * 2
"
self halt.
^ self TR_LoC / self mooseModel TR_totalNumberOfLinesOfCode * self TR_LCOM
Now I have a question because totalNumberOfLinesOfCode does exist on
Model but on TypeGroup
I wrote it like that on FAMIXTypeGroup
TR_totalNumberOfLinesOfCode
<MSEProperty: #TR_totalNumberOfLinesOfCode type: #Number>
<derived>
<MSEComment: 'Total number of lines of code from Understand'>
^ self
lookUpPropertyNamed: #TR_totalNumberOfLinesOfCode
computedAs: [ (self sumNumbers: [ :each | each TR_LoC ]) asFloat ]
How can I access for example totalNumberOfLinesOfCode at the model level?
We had
the problem at Synectique and it is a complex issue
(and no, we did not find a satisfactory solution)
For LOC specifically, in Smalltalk your solution can work, but not in
Java, since classes and methods can contain inner/anonymous classes and
you don't want to count them twice
The problem also exist in Ada (not with classes)
Second, there is also the larger problem of aggregation of a metric at
some higher abstraction level
- some times you want to sum (e.g. LOC) ;
- sometimes it seems more reasonable to average (e.g. cyclomatic
complexity at the level of classes) ;
- sometimes you want to recompute (e.g. coupling between 2 classes can
often not be aggregated from the results of couplings between their
methods) ;
- and also averaging is not always a good solution in itself and you
want something more sophisticated (
http://dx.doi.org/10.1002/smr.1558)
nicolas
--
Nicolas Anquetil -- MCF (HDR)
Project-Team RMod