How many lines of code a year does the average programmer produce? Anyone have any data on this, preferably hard evidence, but gut feelings are welcome, too. (Please include your experience when giving me your guess. :-)
My experience: The better I get, the less code I write to accomplish more. So I think this is a really strange question...
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
And one project I worked on, I replaced about 60,000 lines with around 200, so that could leave me with a negative number of lines per year! I think in order to answer this sensibly, we need to qualify the question a little. You asked the question here, so can I assume the question is restricted to Java? Do you count lines of code auto-generated by wizards, GUI-builders, UML tools etc? Do you have any particular application domain in mind?
It's not an uncommon question, and it's often asked so generally. Here's what I already knew, plus what I found out with some more searching yesterday. Ultimately, coders write code, and measuring Source Lines Of Code (SLOC) is a measure of productivity. Whether or not it is a good measure, I'm not going to touch right now; that's a whole other issue. Some of the best early work was the COCOMO model by Barry Boehm around 1980 (http://www.jsc.nasa.gov/bu2/COCOMO.html). COCOMO stands for "Constructive Cost Model." This was later replaced by the COCOMO II model, developed in the mid 1990's which took into account how software had changed over the years. I should note COCOMO was original designed for man-month estimation, and took SLOC as an input. But in advancing the model, to make it more accurate, means were developed to more accurately predict SLOC for other factors (in COCOMO, these are called Function Points). Yes, things vary greatly, depdning on what you're doing: Assembly language, FORTRAN, C++, HTML, and Lotus Notes, are fundamentally different languages, and you can't compare SLOC to SLOC directly. On the other hand, comparing C++ to Java isn't so unreasonable. You also get variations depending on the type of prgramming, stand-alone, client-server, embedded, web. Different models vary on whether you mean: at the end of the day it's bug free, to generally bug free, to every time you write a new line, and a bug fix in a line is a new line. The complexity of the code also makes a difference, both in trms of doing somehting well understood vs standing on the bleeding edge, as well as working on a project whose end size is 10,000 lines vs 100,000 lines vs 1,000,000 miles. As it grows and gets more complex, productivity goes down. COCOMO officially only counts source code, not comments. I personally disagree with this. Of course, I am very strict about requiring programmers to code (I never write a class or method without at least some javadoc, and often non-javadoc comments, too). In my opinion comments are part of the code, and so should be counted. Some other models do count it. Some general numbers: - My guess is the "theoretical programmer, who did nothing but code (attended no meetings, didn't do any design, no non-source code documentaiton or QA, or anything else), i.e. "here's the design, now code this" would produce about 10-15k per year. - The reality from a couple sources is about 3-4k per year. - A friend of mine told me IBM did a study and found it was the equivalent of 4 bug-free lines of code per day (I'm not sure if that means per work-day, or during the entire year, probably the former). - Somplaces put it at 10 and 50 lines per day, which seems high. http://www.vni.co.kr/product/pdf/CNLdatasheet.PDF and http://www.intelligententerprise.com/010524/feat3_1.shtml
Maybe I'm not understanding your definition of which code to count correctly, but 10 to 50 lines a days seems low to me. I am not that far from the "theoretical programmer," since I rarely need to attend meetings, do most of the design myself, write very few non-source docs, and do some QA. I think it would depend mostly on what type of projects you work on. Writing new apps from scratch goes a lot faster and produces more lines than adding new functionality to existing code.
Joined: Dec 04, 2000
Yes Angela, you are correct. If you look at the COCOMO II model, there are different variables for different types of applications, to account for differing complexities. In terms of the nunmber of lines, try the following. Take a particular project of a few weeks or a few months. Each day, try to keep a count of how many lines of code you've written. (BTW, I was mistaken earlier about the bug fixes. Fixing code as you write it, does not count as a new line. Fixing code someone else wrote 6 months ago, I think that does.) After all is said and done, how much did you write? Of course, you'll get very different numbers depening on whether you count that QA time, or design time. (BTW, the 10 or 50 lines was for the average programmer in industry, not the theoretical one.)
I feel like I have to spend the same time to do testing as to write code. My experience is that, one third of time for desgin( mostly means, discuss with your clients); one third of time write the code, and one third of time for testing. Testing is boring, I alway missing some thing, left some bugges and my manager is not very happy when that happened. It is very hard for me to sit down and to do the testing, I don't know why. So, it's bit of hard to say how many line of code I can write one day. I guess about 100 lines( Language is UniVerse Basic). [This message has been edited by nan sh (edited November 06, 2001).]
Have you tried this Mock Exam Testing Engine yet?<br /><a href="http://www.mycgiserver.com/~nan111/index.html" target="_blank" rel="nofollow">www.mycgiserver.com/~nan111/index.html</a>
I agree with those saying lines of code are at best a very rough measure, but Mark did ask for actual numbers. I just finished a week of working on a new project from scratch (about six 8 hour days or so), and the total number of lines in all the source files is 2621. That includes comments, which is probably about half of the lines, and since I strictly limit my lines to 80 characters, some statements are spread over multiple lines, so if you wanted statements, it would probably be about a third of total number - perhaps 800 or so statements. The compiler output for my classes (not including libraries) is about 50 kB, but as it's a debugging build, I imagine that includes a lot of symbols along with the byte code.
It's a game project I'm doing for myself for fun, and the productivity rate is not too far off from the last game project I did for myself for fun many years ago, which was about 98000 lines in the first year or so. On the other hand, I think it's significantly more than I usually do in a work environment, which goes to show just how much administration and management overhead cut into programming productivity.
And no, it's not copy and paste code, and yes, it has been tested and debugged.