views:

606

answers:

5

Duplicate of http://stackoverflow.com/questions/353380/what-is-a-line-of-code

Should you count end-lines? Should you base it on delimiters in your language, such as semi-colons? Should you count all non-whitespace characters then divide by the average number of non-whitespace character per line?

Maybe the concept of "lines" isn't even useful here. Maybe instead we need to find a way to discuss quantity of code? How do you measure this? Or is it impossible?

A: 

Why do you need to measure it at all?

Lasse V. Karlsen
You need to count LOC (lines of code) for estimating. You should check out Software Estimation by Steve McConnell.
Bobby Cannon
I don't know--perhaps purely an academic question. However, sometimes I want to know how massive this beast is I'm working on compared to past projects. Also if you are required to use tools like COCOMO for estimation, one input is KLOC (kilo lines of code).
Doug T.
A: 

We've been fighting this same issue. The most important point is to measure all projects the same. If you count empty lines in one project then you should count empty lines in the next project. What you want to end up with is a way to compare old project with your new project so you can get a better estimate.

Bobby Cannon
+1  A: 

http://stackoverflow.com/questions/353380/what-is-a-line-of-code

Jon
Did you read the question? It ask what is the best way to measure lines of code not what is a line of code.
Bobby Cannon
+1  A: 

There are a lot of techniques to measure quantity of code. None of them work very well. Any exist metric will want to be used by management to judge the project and as soon as the programmers discover how to game the system, the metric is useless.

http://www.joelonsoftware.com/items/2006/11/10b.html

That being said, I use http://www.dwheeler.com/sloccount/ to boost my ego.

David Poole
A: 

Before answering this question--as with the design of most metrics--it's important to first understand why you're trying to measure the lines of code. For instance, are you trying to gauge the complexity of a portion of code, perhaps to select code that is in most need of being rewritten/refactored? Or alternatively, perhaps you're trying to estimate productivity rates to help influence estimation of the cost of future software projects?

Of course, it's still not an easy question to answer once you've answered the "why" question. Do your software projects span multiple implementation languages? (That can certainly get tricky; 1 line of C code may not be a good rough equivalent/counterpart of 1 line of Perl, for example.)

Reuben