Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When, if ever, is "number of lines of code" a useful metric? [closed]

Tags:

metrics

People also ask

Is lines of code a good metric?

Lines of Code is a Worthless Metric.

Does number of lines of code matter?

So, when programming, the readability of the source code will often be more important than the number of lines of code. The second programming style consists of many more lines of code than the first one. But you could argue that it's easier to read and interpret—especially for novice programmers.

Why are lines of code bad metric for programmer productivity?

The more management is focusing on lines of code, the more incentive the programmer has to expand his code with unneeded complexity. This is undesirable, since increased complexity can lead to increased cost of maintenance and increased effort required for bug fixing.

How many lines of code is good for a program?

As we can see, a new developer will probably write about 100 lines of code a day, or about 25,000 lines of code in a given working year. In contrast, a more senior engineer is probably writing about 20 lines of code a day, or about 5,000 lines of code in a given working year.


I'd say it's when you're removing code to make the project run better.

Saying you removed "X number of lines" is impressive. And far more helpful than you added lines of code.


I'm surprised nobody has mentioned Dijkstra's famous quote yet, so here goes:

My point today is that, if we wish to count lines of code, we should not regard them as "lines produced" but as "lines spent": the current conventional wisdom is so foolish as to book that count on the wrong side of the ledger.

The quote is from an article called "On the cruelty of really teaching computing science".


It's a terrible metric, but as other people have noted, it gives you a (very) rough idea of the overall complexity of a system. If you're comparing two projects, A and B, and A is 10,000 lines of code, and B is 20,000, that doesn't tell you much - project B could be excessively verbose, or A could be super-compressed.

On the other hand, if one project is 10,000 lines of code, and the other is 1,000,000 lines, the second project is significantly more complex, in general.

The problems with this metric come in when it's used to evaluate productivity or level of contribution to some project. If programmer "X" writes 2x the number of lines as programmer 'Y", he might or might not be contributing more - maybe "Y" is working on a harder problem...


When bragging to friends.