0

say lenchar be the number of characters in source code, is it a valid measure for the length of source code?

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52

1 Answers1

1

No, it's not. People could "game" your metric without leading to quality.

If you're metric is "lots of characters == good" then you end up with very large source files & class that are maintenance nightmares, often with very poor names (once again, just to game your metric) or an obscene amount of comments:

var excessivelyLongVariableNameSoWhenBonusTimeComesAroundAustinIsRewardedMightily = 0;

/*
This for loop loops over the entire collection (as implemented in IEnumerable 
and is fully explained later).  My goal here was a O(1) implementation but 
since that's highly unlikely (possible mathematically impossible but I'm no 
PhD so I'll just leave it to them.

Oh yeah, the motive -- I'm trying sum the integers between 0 and 9 (inclusive)
*/
for(int i = 0; i < 10; i++)
     sum += i;

Conversely, when "lots of characters == bad" then you end up with very poor names:

var x = 1

Executable lines would be better but even then you're open to "gaming." But even then, one could game it by pumping in a bunch of no-op lines.

You're most likely better off with metrics like...

  • Does it work?
  • Does it work quickly enough for our needs?
  • Is it tested?
  • etc.
Austin Salonen
  • 49,173
  • 15
  • 109
  • 139