Tag Archives: code

How much code can a coder code?

Lines of code (LOC) is a simple way to measure programmer productivity. Admittedly it is a flawed metric. As Bill Gates famously said “Measuring programming progress by lines of code is like measuring aircraft building progress by weight”. But it is at least easy to measure.

So how much code do programmers average per day?

  • Fred Brooks claimed in ‘The Mythical Man-Month’ that programmers working on the OS/360 operating system averaged around 10 LOC per day.
  • Capers Jones measured productivity of around 16 to 38 LOC per day across a range of projects.
  • McConnell measured productivity of 20 to 125 LOC per day for small projects (10,000 LOC) through to 1.5 to 25 LOC per day for large projects (10,000,000 LOC).

It doesn’t sound a lot, does it? I’m sure I’ve written hundreds of lines of code on some days. I wondered how my productivity compared. So I did some digging through my own code. In the last 12 years I have written somewhere between 90,000 and 150,000 C++ LOC (depending on how you measure LOC) for my products: PerfectTablePlan, Hyper Plan and Keyword Funnel. This is an average of round 50 lines of code per working day. Not so different from the data above.

I also looked at how PerfectTablePlan LOC increased over time. I was expecting it to show a marked downward trend in productivity as the code base got bigger, as predicted by McConnell’s data. I was surprised to see that this was not the case, with LOC per day remaining pretty constant as the code base increased in size from 25k to 125k.

loc

Some qualifications:

  • I give a range for LOC because ‘line of code’ isn’t very well defined. Do you count only executable statements, or any lines of source that aren’t blank?
  • My data is based on the current sizes of the code bases. It doesn’t include all the code I have written and then deleted in the last 12 years. I have just spent several months rewriting large parts of PerfectTablePlan to work with the latest version of Qt, which involved deleting large swathes of code.
  • It doesn’t include automatically generated code (e.g. code generated by the Qt framework for user interfaces and signals/slots code).
  • I only counted code in products shipped to the user. I didn’t count code I wrote for licence generation, testing etc.
  • All the code is cross-platform for Windows and Mac, which makes it more time consuming to write, test and document.
  • Programming is only one of the things I do. As a one-man-band I also do marketing, sales, QA, support, documentation, newsletters, admin and nearly everything else. I have also done some consulting and training not directly related to my products in the last 12 years.

Given that I probably spend less than half my time developing (I have never measured the ratio), my productivity seems fairly good. I think a lot of this may be the fact that, as a solo developer, I don’t have to waste time with meetings, corporate bullshit and trying to understand other people’s code. Also writing desktop Windows/Mac applications in C++ is a lot easier than writing an new operating system with 1970s tools.

50 lines of code per day doesn’t sound like a lot. But the evidence is that you are unlikely to do much better on a substantial project over an extended period. Bear that in mind next time you estimate how long something is going to take.

If you have data on LOC per day for sizeable projects worked on over an extended period, please post it in the comments. It will only take you a few minutes to get the stats using Source Monitor (which is free).

 

 

 

 

 

 

A code pretty printer product idea

I use QtCreator for my C++ development IDE. It is very good. But it doesn’t always lay out my C++ code the way I want it to. In particular the refactoring operations mess up my white space. I want my code to look like:

void foo( int* x, int& y )

But it keeps changing it to:

void foo(int *x, int &y)

Grrrrrr.

So I am constantly battling with QtCreator to layout my code how I like it. There are plenty of C++ pretty printers around. I played with some of the leading ones using UniversalIndentGUI, but I couldn’t get any of them to layout my code quite how I wanted. Maybe they could have done it, but I got fed up with fiddling with the settings.

What I need is a code pretty printer that I can configure to layout my code exactly how I want without me having to tweak 100 settings.

Ideally I want a code pretty printer that I can train. So I just point it at a few files of my code that are laid out how I want and it works out all my preferences (where to put braces, how to indent case statements, where to put the * for a pointer declaration etc) and can then apply them to any other code. It wouldn’t need a GUI. Or perhaps just enough to select the training files and then preview the results on other files.

I have no idea if this is a viable product idea. But I would pay $100 for it, if it worked well. Perhaps bigger software companies would pay a lot more? Or maybe something like this already exists and I just don’t know about it?