Measuring productivity by lines of code

Peter Hansen peter at engcorp.com
Sun Oct 8 18:15:15 EDT 2000


Michal Wallace wrote:
> Do people really pay by line of code? I want THAT job.. :)
> 
> # old way: for x = 1 to 10
> 
> # new way: :)
> x = 1
> x = 2
> x = 3 ...

Don't laugh.  I once maintained (read, rewrote) some code for an
embedded system with a tiny LCD screen, written by an electrical
engineer just learning C.  The code I started with included a huge
module containing many functions such as this:

printHELLO(void)
    {
    lcdpos = 0;
    lcdmove(lcdpos);
    lcdout('H');
    lcdmove(++lcdpos);
    lcdout('E');
    lcdmove(++lcdpos);
    lcdout('L');
    lcdmove(++lcdpos);
    lcdout('L');
    lcdmove(++lcdpos);
    lcdout('O');
    }

These were then called by a higher-level module, with if statements to
decide which function to call.  I made judicious use of strings, for
loops, and switch statements....

It was not the first time I've been guily of negative productivity
(counting lines of code produced), as I ended up shrinking a 32K ROM
image to about 19K in a couple of days...

To stay a little on-topic, just the other day I rewrote some code
written by an aspiring electrical engineer who was just learning Python
(but was experience in C).  I had negative productivity again, after
removing a huge number of return value tests (judicious use of
exceptions), explicit argument testing (use getopt module), and program
logic (went OOP with some parts).  

Not quite a 25-to-1 ratio, but at least two or three to one...  and it's
maintainable now.

-- 
Peter Hansen



More information about the Python-list mailing list