Fog Creek Software
Discussion Board




Statistics - reading code vs. writing code

I'm looking for some quotable statistics for some marketing materials.  I highly suspect that many developers spend more time reading code (looking for bugs, or just plaing maintenance) then writing new code.  Does anyone know where I might find some quotable statistics about this?  ...or to the contrary, if I'm incorrect.  Something like an academic paper or other reference-able source would be great.

And for that matter, what about yourselves?  Do we spend more time reading existing code, or writing new code?

JT
Friday, December 26, 2003

I just finished reading Code Complete by Steve McConnell and I'm pretty sure ha gave some statistics in there. Unfortunately I don't have it here right now...

sgf
Friday, December 26, 2003

"And for that matter, what about yourselves?  Do we spend more time reading existing code, or writing new code?"

Does a writer spend more time writing or reading? i think it's obvious most programmers spend more time reading than writing.

Tom Vu
Friday, December 26, 2003

Not to sound like a famous politician, but it depends on what we mean by "read." 

consider any single line of code:

x=y;

I wrote it once and at a minimum will read it twice. Once while actually typing it and again to verify completeness. 

Consider any more complex structure:
// statements_for.cs
// for loop
using System;
public class ForLoopTest
{
  public static void Main()
  {
      for (int i = 1; i <= 5; i++)
        Console.WriteLine(i);
  }
}

While I consider myself fairly good, I would be kidding to say I could type even this simple example, error free without reading it, nor would I want to.

MSHack
Friday, December 26, 2003

The *time* spent reading while writing is, I think, attributable entirely to writing. If you insist, adopt a simple rule that says that, on a first day a line of code comes into existence or is modified, you attribute the time it took entirely to writing; From that moment on, every time you read it, it's reading.

I think that even for productive programmers, reading:writing is 90:10 or even 99:1. And before you claim that sounds ridiculous, consider that the industry average of production quality lines-per-hour produced (meaning, reasonably bug free and spec compatible). is, last I heard, ~ 10. Now consider, where all that time is spent.

Ori Berger
Friday, December 26, 2003

Not necessarily on reading code, though.

Brad Wilson (dotnetguy.techieswithcats.com)
Friday, December 26, 2003

The 10 lines per day is an average for production-ready code, not including comments or whitespace.  The "days" includes the time in design, and the testing and debugging as well as other activities like meetings, brainstorming, and requirements gathering.

I just finished a project that took about 4 months for design and requirements, with 1 month for coding and another month to make it production-ready.  So the code produced would get averaged out over 6 months.

T. Norman
Friday, December 26, 2003

Ori, where did you hear 10 per hour? Last I heard was 13 per day average and 40 for top producers. Those numbers are surely old though and I have suspected productivity is higher now and have been looking for some decent stats. Thanks.

Dennis Atkins
Friday, December 26, 2003

And yes, it's understood that these are averaged out across total effort over a year and its non-space non-comment.

Dennis Atkins
Friday, December 26, 2003

Those numbers are also net of rewrites and deletions.  If you write 500 lines, then subsequently modify 100 and remove 200 of them to make it production ready, it counts as just 300.

T. Norman
Friday, December 26, 2003

40 lines for "top producers"?

I guess you mean "top LOC producers" and not "top programmers".  Because from what I've read, the top programmers don't really write much more or less code per day than average.  They just get much more functionality out of their lines of code, by finding simpler solutions to complex problems.

T. Norman
Friday, December 26, 2003

JT, there are many different types of developers.  Maintenance programmers and oss people will spend most of their careers reading code. Developers will spend very little because they create new code.

me
Saturday, December 27, 2003

I agree with T. Norman. Better developers tend to write less code, not more. They also tend to relish in ripping out code whenever possible.

What's that quote? "The sign of product maturity is when the code-base starts shrinking instead of growing."

Brad Wilson (dotnetguy.techieswithcats.com)
Saturday, December 27, 2003

Still, in extreme cases the top developers probably do write more lines of code per day AND get more functionality per line.  Otherwise Doom would probably still be unfinished if they were working at a 10-20 LOC/day rate.

Project size also affects things.  In general, the more people on a project is the less % of the time you spend coding.  So on a smaller project your higher LOC/day can mean actual increased productivity, and not just redundant fluff.

T. Norman
Saturday, December 27, 2003

Maybe you've never worked with crap developers, T Norman. These are people who will cut and paste huge blocks of garbage, fiddle with it till it sort of does what's required, then have a great talk with the project manager. They're usually good talkers.

me
Saturday, December 27, 2003

I'm happy to see someone ask this question.
I've asked it once during a meeting. I gave my personal answer (95:5) and they looked at me like as if I was an E.T.
One of my colleagues even answered 5:95.
My conclusion was that, as far as code is concerned, accelerating the reading phase is more valuable than accelerating the writing phase.

Pakter
Sunday, December 28, 2003

*  Recent Topics

*  Fog Creek Home