Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Line Counts are (mostly) Meaningless

by tedv (Pilgrim)
on Apr 27, 2001 at 22:11 UTC ( #76203=note: print w/replies, xml ) Need Help??

in reply to Line-counts of perl programs/modules

In my experience, Number of Lines is a completely meaningless value. Here's a great example. Some people on my programming team spent 4 months programming some software which took 30,000 lines (as counted by wc -l). They were applauded for doing "good work". Later, I spent a mere 2 days culling over the code and removing 3,000 lines. I was also applauded. But if lines of code is a measure of work... doesn't removing lines mean I'm destroying work?

Not at all, and everyone knows this. When I sorted through the code, I was making it much more readable, understandable, and just take advantage of many features which Perl allowed.

Lines of code only measures the programmer's understanding of the problem.

It's very important to realize this. "Everything should be made as simple as possible, but not simpler." If you have too few lines of code, you might not fully understand the problem. If you have too many lines of code, maybe you've missed an elegant solution. But there's just no way to know if a solution is "good" or "bad". You can only compare it to other solutions..

A better metric of how well code is written is to go over a section of code and explain it to someone else. Time how long it takes for someone else to understand the body of code. Your metric is time / lines. Note that line counts include comments, because comments aide in the (mis)understanding of the problem. This metric gives you a far better understanding of true code ellegance. Well written code will be easier to understand than poorly written code.


Replies are listed 'Best First'.
Re: Line Counts are (mostly) Meaningless
by lindex (Friar) on Apr 27, 2001 at 22:40 UTC
    I like to think of it in a procedure to procedure mannor. Say I have a bit of text data or data structure or some sort of permutation or whatever, more often than not the less number of lines of code(or char's of code in some cases) the better the method of doing that procedure. As well as from my own personal experience, the more and more I code perl the shorter my scripts get :) So as far as amount of work goes with programming, its not(at least for me) the number of lines of code, its how long the programmer spent coding those lines of code.

    /****************************/, /*****************************/
      In the words of Blaise Pascal, "This letter is longer than usual because I lack the time to make it short."


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://76203]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2022-08-18 04:30 GMT
Find Nodes?
    Voting Booth?

    No recent polls found