On Fri, Sep 22, 2017 at 10:15 AM, Nicolas Anquetil <nicolas.anquetil@inria.fr> wrote:



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)

SourceLanguage object can't manage this info?
I think we already discussed it in the context of C/CPP (Modules vs. Class) and this is how we started to manage variations amongst these two.

Ideally, one would want to create several metrics computation strategies so that these can be shared amongst languages.

usman
 

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

_______________________________________________
Moose-dev mailing list
Moose-dev@list.inf.unibe.ch
https://www.list.inf.unibe.ch/listinfo/moose-dev