I have often come across claims that source code is read much more than it is written and just wanted to do a little calculation like:

If you write a line that takes me 5 minutes longer to read because you were to lazy to write a comment for 5 minutes it will cost us n*X if 5 minutes of programmer time cost X.

Then I realized that I not only lack n to do the calculation but also have never seen any evidence for the claim that code is read much more than it is written.

Is that just a fishy "well it is only written once so it has to be read a lot more" argument or are there any studies on the subject that you know of?

  • 2
    Related: industry averages for time spent on maintenance – user40980 May 3 '13 at 15:23
  • 4
    "If you spent five minutes writing a comment, you should have spent five minutes making the code so obvious that it didn't need that comment." – Anthony Pegram May 3 '13 at 15:50
  • 6
    The statement is based on developers' experience. Talk to any average or good developer, they'd most probably confirm that they spend more time reading code than writing it. – superM May 3 '13 at 15:58
  • 1
    see also: Is “as long as it works” the norm? and What data is available regarding cowboy coding? The latter feels pretty much like an (inverted) duplicate, "how many apps have failed to function as intended / crashed / removed because of errors made by, in essence, sloppy coding... Is there any data about this type of development?" – gnat May 3 '13 at 23:28

For a lower bound, you could look at how many revisions typical files have in your source control. You have to read it at least once in order to make a change. However, if you actually tracked yourself over the day, I think you would find the actual value much higher.

  • I should write a Visual Studio plug-in to track how many times a file is opened. :) – Sarien May 3 '13 at 16:55
  • 1
    @Sarien: And why not make it Tobii-enabled? Not only would you have line-by-line statistics, but even character by character statistics! – Allon Guralnek May 10 '13 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.