1

I have to measure how many code lines in a project and a release (made between two labels). I can do that and there's no problem with that for me.

My question is about the weight I have to "attach" to the files which consist the project. I have to weigh the files in a relative way so we finally get a weighted mark. For instance: If I have CPP project, I believe i have to give a different weight to cpp file; h files and text files since the time invested in each file type is quite different.

Furthermore, I may consider to provide a different mark for added lines, removed and changed lines, since sometimes it takes more time to change an existing line (rather than add a new one). However I'm not sure yet about that.

Do you know where can I find good reading material about that? My question is quite generic - I'd like to read also about Java, C# and any code language.

Thank you

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
Tamir Gefen
  • 1,128
  • 2
  • 18
  • 35
  • 6
    sorry, I know you dont wanna hear that... but measuring anything in lines of code is the same as measuring an airplain by the total weight "done yet" in relation to "is it able to fly now?" - ive seen hundreds of lines that could be refactored into 10 lines "done right". – Najzero Sep 24 '13 at 08:01
  • 5
    I really wouldn't treat LoC as a meaningful metric. For example, compare code that uses Linq extensively with code that doesn't. LoC is a 1980's style metric. http://stackoverflow.com/questions/184071/when-if-ever-is-number-of-lines-of-code-a-useful-metric – Matthew Watson Sep 24 '13 at 08:02
  • LoC is a pretty good metric of *effort* put into a project. Someone who wrote the code with LINQ has put much less effort into it than someone who wrote an equivalent code in assembly. Of course effort != productivity nor effort != quality. – Piotr Kołaczkowski Sep 24 '13 at 08:15
  • @PiotrKolaczkowski Well it might not really take much effort to initialise a large array using `array[0] = 0; array[1] = 0; array[2] = 0;` etc, one statement per line ;) – Matthew Watson Sep 24 '13 at 08:35
  • Any LoC metrics silently assume programmers keep line lengths sane and write clean code. It is obvious that any code can be always made longer. – Piotr Kołaczkowski Sep 24 '13 at 09:43

1 Answers1

2

You might be interested in COCOMO II model. However, beware that judging code by number of lines might be very misleading - don't use it to compensate your developers, or they will start writing very verbose code and you'll go bankrupt very quickly ;)

Piotr Kołaczkowski
  • 2,601
  • 12
  • 14
  • Thanks. I found this: http://en.wikipedia.org/wiki/COCOMO . Are you sure it refers to the weight? I couldn't find so – Tamir Gefen Sep 24 '13 at 09:27
  • COCOMO II uses lots of various weights for things like team skill, project difficulty, etc. I don't know if it uses programming-language dependent weights, though. Howewver, it is a very controversial topic - some people will tell Python code is 10x shorter than equivalent C++ code, some will tell it is only 2x, and the only sure thing is: it depends on the project and programmer skill. – Piotr Kołaczkowski Sep 24 '13 at 09:41