views:

182

answers:

10

We are documenting our software development process. For technical people, this is pretty easy: iterative development with internal milestones every four weeks, external every 3 months.

However, the purpose of this exercise is to expose things for our project management in terms that they can understand. Specifically, these non-technical managers need metrics that they can understand.

I understand our options for metrics well and have proposed a whole set (requirements met and actual costs vs. budgeted costs are two of my favorites). However, we do have some old hands involved and they tend to hang onto metrics like SLOC.

I understand the temptation of SLOC: it seems easy for non-software people to understand and it seems like the closest analog of a physical thing (it's just like counting punched cards back in the old days!).

So here's the question: how can I explain the dangers of SLOC to a non-technical person?

Here's some concrete motivation: we work on a fairly mature deployed system that has years of history behind it. As we add features, SLOC tends to stay approximately level or even decrease (refactoring removes old / dead code, new features are really just adjustments of existing, etc). To a non-programmer manager, a non-increasing SLOC in a development project is perplexing at best....

+4  A: 

pretty bad (-: A much better idea would to cover the test cases, rather than code...

the idea is: developer should checkin a test case that fails, then checkin the fix in next build, and test case should pass ... just measure how many test cases the developer added.

as a bonus .. do a coverage ( conditionals coverage is better than line coverage here ).

Vardhan Varma
@Vardhan, I totally agree that test cases and coverage are better. That said, I actively refuse to allow measurement of individual people for project management people. We're a team and that sort of thing stays inside the team.
Bob Cross
+2  A: 

Show them the difference between:

for(int i = 0; i < 10; i++) {
    print i;
}

and

print 0;
print 1;
print 2;
...
print 9

And ask them whether 10 SLOC or 3 SLOC is better.


In response to the comments:

  1. It doesn't take long to explain how a for loop works.

  2. After you show them this, say "we now need to print numbers up to 100 - here's how you make that change." and show how much longer it takes to change the non-DRY code.

Skilldrick
**I** would agree with you that the first case is better, but the 'non-technical' person might agree that the second case is. And, they might be right, the second case will compile/run faster and require less memory =)
mkoistinen
@Skilldrick, I agree that you and I both look at this example (or similar on Wikipedia) and say, yes, of course. However, non-programmers see "gibberish" and "more gibberish". It's sort of like using a word in its own definition....
Bob Cross
@mkoistinen: The compiler can unroll the loop for you if it's actually a good idea. And bloated binaries with hand-unrolled loops like this often perform worse even though intuitively it seems like the computer should be doing less "work".
Chuck
+5  A: 

Someone said :

"Using SLOC to measure software progress is like using kg for measuring progress on aircraft manufacturing"

It is totally inappropriate as it encourages bad practices like :

  • Copy-Paste-Syndrome

  • discourage refactoring to make things easier

  • Stuffing with meaningless comments

  • ...

The only use is that it can help you to estimate how much paper to put in the printer when you do a printout of the complete source tree.

Peter Tillemans
@Peter, I had heard that comment before but don't know the citation. Do you have a reference for it?
Bob Cross
@Bob According to an article I found online it was Bill Gates : http://www.dev102.com/2008/09/09/measuring-programming-progress-by-lines-of-code/
Peter Tillemans
@Bob Cross: I think it is usually attributed to Bill Gates. (Which is kind of ironic, considering what bloated monsters Windows and Office are. Windows is around 50 million SLOC, Office around 270 million. That's over 300 million SLOC, using all the tools 2010 has to offer, to achieve pretty much the same thing Alan Kay and his group did in 1976 with 60 *thousand* SLOC.)
Jörg W Mittag
And like Bill's comment about "Who'd need more than 640K?" he was totally off the mark. If you talk to people that design airplanes, they *fight* to remove every last ounce of weight. This is the entire excuse for the Boeing Dreamliner. People should do that for code, too. (Its good to be an icon, people will quote you no matter how dumb your remark).
Ira Baxter
A: 

SLOC can be changed dramatically by putting extra empty lines ("for readability") or by putting or removal of comments. So relying on SLOC only can lead to confusion.

Eugene Mayevski 'EldoS Corp
Whitespace (extra lines) and/or comments are not counted as part of SLOC.
confusedGeek
this is not something non-technical staff needs to know.
Eugene Mayevski 'EldoS Corp
+3  A: 

Hammerite
@Hammerite, sure, it's easy to see Dilbert in everything if you try to. That said, we can't just say "all metrics are dumb." We have to suggest something better. That said, SLOC definitely IS dumb.
Bob Cross
You could edit the strip to remove panels 3, 4 and 5. Then the message would become less "metrics are dumb" and more "ill-considered metrics are dumb", and the analogy between SLOC and PHB's "number-of-words" metric would remain clear.
Hammerite
@Hammerite We'll have to subtract panels you delete.
jleedev
A: 

Why SLOC is bad as an individual metric of productivity:
Think of code as a block of clay/stone. You need to carve, say 10 statues. It's not how many statues you carve that counts. It's how well you've carved it that counts. Similarly it's not how many lines you've written but how well they are functioning. In case of code LOC can backfire as a metric this way.
Productivity also changes when writing a complex piece of code. It takes a second to write a print statement but a lot of time to write a complex piece of logic. Not all fingers are equal.

How SLOC can be used for your benefit:
I think SLOC for defect % is a good metric. Yes the difficulty level comes into play but this is a good parameter that the managers can throw around while doing business. Try to think from their perspective too. They don't hate you or your work, but they need to tell customers that you're the best and for that they need something tangible. Give them what you can :)

Sidharth Panwar
@Sidharth, in a modern language, I feel that SLOC is too fine-grained. Example: Findbugs reports bugs per Java class and package. THAT is more useful - we can look at a list of classes and say that "this is the worst class / package" and we should organize a focused effort. Bugs per line of code is hard to take action on - what should we do?
Bob Cross
@Bob If you have better metrics then there's no point in sticking to SLOC. You can explain this to the managers. Why they are still struck with it is because the industry still holds on to it. Tell them that from QA point of view it's better to have findbug type of reports. Try and understand "their" focus, if it's internal monitoring they'll agree on findbugs, if it's external then they'll still need SLOC because that's what the client understands.
Sidharth Panwar
@Sidarth, in case it isn't clear, some of the people involved ARE the clients. They aren't savvy enough to understand a Findbugs (especially since they're looking for a "size" metric in this category) - they aren't technical in our area.
Bob Cross
+1  A: 

You don't judge how good(how many features,how it performs..) a plane is based on its weight(sloc).

When you want your plane to fly higher, longer and perform better, you don't add weight to it. You replace parts of it with lighter/better materials. You strip off parts you don't need as to not add unnecessary weight.

nos
“Measuring programming progress by lines of code is like measuring aircraft building progress by weight.” — Bill Gates
jleedev
+3  A: 

The issue with SLOC is that it's an easy metric to game. Being productive does not equate to producing more code. So the way I've explained it to people baring what Skilldrick said is this:

  1. The more complicated something gets the harder it is to understand it.
  2. The more lines there are to read the harder it gets to understand it.
  3. Before I add a new feature or fix a bug I need to understand it.
  4. Understanding takes time.
  5. Time costs money.

Smaller code -> easier to understand -> cheaper to add new features

Bean counters can understand that.

wheaties
@wheaties, okay, that 5 step process is actually quite compelling. Thanks.
Bob Cross
A: 

Why don't they understand that the SLOC hasn't changed, but the software does more than it did yesterday because you've added new features, or fix bugs?

Now explain it to them like this. Measuring how much work was done in your code by comparing the lines of code is the same as measuring how many features are in your cell phone comparing it by size. Cell phones have decreased in size over 20 years time while adding more features because of technological improvements and techniques. Good code follows this same principal as we can express the same logic in fewer and fewer lines of code, making it faster to run, easier to maintain, and simpler to understand as we improve our understanding of the problem and introduce new techniques for development.

I would get them to focus on the business value returned through feature development, maintenance, and bug fixes. If whoever is happy with the software says they can see improvement don't sweat the SLOC.

Go read this:

http://stackoverflow.com/questions/3800707/what-is-negative-code

chubbard
+1  A: 
Richard
@Richard, I agree that you and I would understand that length != better. However, for non-technical people that are used to projects that need to produce very long cables (for example), length is a measure that they understand. The breakdown is that software == knowledge. It doesn't have a physical analog.
Bob Cross