views:

6854

answers:

13

Everybody always says that they can beat the "10 lines per developer per day" from the "Mythical Man Month", and starting a project, I can usually get a couple hundred lines in in a day.

But at my previous employer, all the developers were very sharp, but it was a large project, over a million lines of code, with very onerous certification requirements, and interfacing with other multiple-million line projects. At some point, as an exercise in curiosity, I plotted lines of code in the shipping product in my group (not counting tools we developed), and sure enough, incrementally, it came to around 12 lines net add per developer per day. Not counting changes, test code, or the fact that developers weren't working on the actual project code every day.

How are other people doing? And what sort of requirements do you face (I imagine its a factor)?

+10  A: 

You should stop using this metric, it is meaningless for the most part. Cohesion, coupling and complexity are more important metrics than lines of code.

Otávio Décio
I was not using it as a productivity metric. This was a private exercise for my own curiosity.
Matthias Wandel
Fair enough. Even so it is hard to answer without a more precise definition of what is to be considered a line of code.
Otávio Décio
@Matthias: I should edit that into the OP if I were you, I for one would have been less... aggressive :P
annakata
+6  A: 

It's easy to get a couple of hundred lines of code per day. But try to get a couple of hundred quality lines of code per day and it's not so easy. Top that with debugging and going through days with little or no new lines per day and the average will come down rather quickly. I've spent weeks debugging difficult issues and the answer being 1 or 2 lines of code.

Jeffrey Hines
Indeed. But you will hit that scenario more often as the project gets bigger. I have written perfect 10 line programs that had no bugs. Its all a matter of scale.
Matthias Wandel
There aren't programs that have no bugs.
Daniel Moura
Bah! your grammar has bugs...
Robert Lamb
A: 

One suspects this perennial bit of manager-candy was coined when everything was a sys app written in C because if nothing else the magic number would vary by orders of magnitude depending on the language, scale and nature of the application. And then you have to discount comments and attributes. And ultimately who cares about the number of lines of code written? Are you supposed to be finished when you've reach 10K lines? 100K? So arbitrary.

It's useless.

annakata
How do you describe the size of a project then?
Matthias Wandel
If it's from "The Mythical Man-Month", it predates C by a long ways. In that book, Brooks looked at the idea that programmer output in lines/day is fairly constant despite the language, and surmised that writing in a more expressive language (fewer lines per functionality unit) would result in more productive programmers. He was aware that the number would vary widely (his rule of thumb was that operating systems were about 9 times harder than application programs).
David Thornley
Discrete code units, connectivity points (that is, unit interaction), tiers, classes (in OOP) ... there are about a million ways. KLOCs isn't really a good measure other than as a *potential* unit of complexity. (EG, "this took 3 weeks to debug because I had to pore through 4 KLOCs to find it!")
John Rudy
@David: I know where it's from, I can read the question and I've got said book in front on the shelf in front of me right now. Interestingly the first published date also says it's post C by 3 years. My point - clearly badly made - was that it's archaic, and further that the very concept is useless. Hah! It really is biblical.
annakata
Well, we had lots of connectivity points and such. But how do you even count those? When does something become a connectivity point? When does a class matter?Compiled code size is probably a better metric within a given system and language, but it varies across systems.
Matthias Wandel
David Thornley
+27  A: 

On one of my current projects, in some modules, I am proud to have contributed a negative line count to the code base. Identifying which areas of code have grown unnecessary complexity and can be simplified with a cleaner and clearer design is a useful skill.

Of course some problems are inherently complex and required complex solutions, but on most large projects areas which have had poorly defined or changing requirements tend to have overly complex solutions with a higher number of issues per line.

Given a problem to solve I much prefer the solution that reduces the line count. Of course, at the start of small project I can generate many more than ten lines of code per day, but I tend not to think of the amount of code that I've written, only what it does and how well it does it. I certainly wouldn't aim to beat ten lines per day or consider it an achievement to do so.

Charles Bailey
+1 for contributing negative lines. I once worked on a small project where I shrunk the line count from 15K to 5K while adding new features (and greatly decreasing bug count and increasing speed).
rmeador
+7  A: 

There is no such thing as a silver bullet.

A single metric like that is useless by itself.

For instance, I have my own class library. Currently, the following statistics are true:

Total lines: 252.682
Code lines: 127.323
Comments: 99.538
Empty lines: 25.821

Let's assume I don't write any comments at all, that is, 127.323 lines of code. With your ratio, that code library would take me around 10610 days to write. That's 29 years.

I certainly didn't spend 29 years writing that code, since it's all C#, and C# hasn't been around that long.

Now, you can argue that the code isn't all that good, since obviously I must've surpassed your 12 lines a day metric, and yes, I'll agree to that, but if I'm to bring the timeline down to when 1.0 was released (and I didn't start actually making it until 2.0 was released), which is 2002-02-13, about 2600 days, the average is 48 lines of code a day.

All of those lines of code are good? Heck no. But down to 12 lines of code a day?

Heck no.

Everything depends.

You can have a top notch programmer churning out code in the order of thousands of lines a day, and a medium programmer churning out code in the order of hundreds of lines a day, and the quality is the same.

And yes, there will be bugs.

The total you want is the balance. Amount of code changed, versus the number of bugs found, versus the complexity of the code, versus the hardship of fixing those bugs.

Lasse V. Karlsen
Amen! (plus spaces to meet 15 char min)
Nate Bross
Note, those statistics were calculated by DPack (http://www.usysware.com/dpack/).
Lasse V. Karlsen
Perhaps the 10 lines per day rule doesn't apply to something smaller, like the class library you wrote (I assume by yourself). Much of Brooks' numbers come from large projects (IBM's OS360), which is on a fundamentally different scale than your class library. My guess is that Brooks' observation is (frequently) valid for large projects that require many people and significant human communication networking, but invalid for smaller projects.
sheepsimulator
+5  A: 

Without actually checking my copy of "The Mythical Man-Month" (everybody reading this should really have a copy readily available), there was a chapter in which Brooks looked at productivity by lines written. The interesting point, to him, was not the actual number of lines written per day, but the fact that it seemed to be roughly the same in assembler and in PL/I (I think that was the higher-level language used).

Brooks wasn't about to throw out some sort of arbitrary figure of productivity, but he was working from data on real projects, and for all I can remember they might have been 12 lines/day on the average.

He did point out that productivity could be expected to vary. He said that compilers were three times as hard as application programs, and operating systems three times as hard as compilers. (He seems to have liked using multipliers of three to separate categories.)

I don't know if he appreciated then the individual differences between programmer productivity (although in an order-of-magnitude argument he did postulate a factor of seven difference), but as we know superior productivity isn't just a matter of writing more code, but also writing the right code to do the job.

There's also the question of the environment. Brooks speculated a bit about what would make developers faster or slower. Like lots of people, he questioned whether the current fads (interactive debugging using time-sharing systems) were any better than the old ways (careful preplanning for a two-hour shot using the whole machine).

Given that, I would disregard any actual productivity number he came up with as useless; the continuing value of the book is in the principles and more general lessons that people persist in not learning. (Hey, if everybody had learned them, the book would be of historical interest only, much like all of Freud's arguments that there is something like a subconscious mind.)

David Thornley
A thought about different programmer productivity - In my experience, a mediocre programmer will take x times longer to solve a given problem, but also, unfortunately, write x times more code while at it. So by the simple "lines of code per day", the mediocre programmer is just as productive.
Matthias Wandel
+10  A: 

I think the number of lines added is highly dependable upon the state of the project, the rate of adding to a new project will be much higher than the rate of a starting project.

The work is different between the two - at a large project you usually spend most of the time figuring the relationships between the parts, and only a small amount to actually changing/adding. whereas in a new project - you mostly write... until it's big enough and the rate decreases.

Liran Orevi
Indeed. Early on in said project the net ad was much larger.
Matthias Wandel
+2  A: 

I think this comes from from the waterfall development days, where the actual development phase of a project could be as little as 20-30% of the total project time. Take the total lines of code and divide by the entire project time and you'll get around 10 lines/day. Divide by just the coding period, and you'll get closer to what people are quoting.

pgs
+1  A: 

I think project size and the number of developers involved are big factors in this. I'm far above this over my career but I've worked alone all that time so there's no loss to working with other programmers.

Loren Pechtel
Small projects help, and so does solitary. I was initially shocked to see that we hit this historical figure, at least incrementally. At the start of said project, my productivity was at least 10x higher.
Matthias Wandel
A: 

Hello all,

I am working for a company doing a C# application that involves database access (SQL Server, including T-SQL code). In 6 months, I have written around 40,000 lines of C# and around 10,000 lines of T-SQL. Do you guys think that these are good numbers? Consider my code is effective, can you rate my performance out of 10?

Please email me with your answers: [email protected]

This is a new question, not an answer
Emilio M Bumachar
A: 

Steve McConnell gives an interesting statistic in his book "Software Estimation" (p62 Table 5.2) He distinguish between project types (Avionic, Business, Telco, etc) and project size 10TLOC, 100TLOC, 250TLOC. The numbers are given for each combination in LOC/StaffMonth. E.G. Avionic: 200, 50, 40 Intranet Systems (Internal): 4000, 800, 600 Embedded Systems: 300, 70, 60

Which means: eg. for Avionic 250TLOC project there are 40(LOC/Month)/22(Days/Month) == <2LOC/day!

Valentin Heinitz
A: 

Good planning, good design and good programmers. You get all that togheter and you will not spend 30 minutes to write one line. Yes, all projects require you to stop and plan,think over,discuss, test and debug but at two lines per day every company would need an army to get tetris to work...

Bottom line, if you were working for me at 2 lines per hours, you'd better be getting me a lot of coffes andmassaging my feets so you didn't get fired.

lcabral
A: 

I like this quote:

If we wish to count lines of code, we should not regard them as "lines produced" but as "lines spent". - Edsger Dijkstra

Some times you have contributed more by removing code than adding

rlovtang