Skip to content
May 7 2008

Lines of Code Should Be Like a Golf Score

I get really aggravated when I hear developers talk about how many lines of code they write. You know the people I’m talking about. The ones who make brash statements like, “I wrote 25,000 lines of code last month” or “Of course it’s buggy, it has 100,000 lines of code”.

What those people don’t get is that statements like those scare the crap out of developers who know better. When someone makes statements like that, it tells me all I need to know about their approach to writing quality software, which is to say, severely flawed.

One of my favorite things to do is not to write additional code, but to remove code, either because it’s no longer needed or by way of refactoring. Nothing makes me happier than shrinking a codebase.

It’s not about how many lines of code you write, it’s about how many lines of code you don’t write (while providing the required functionality). And it’s those developers who you want to work with.

Similar Posts:

  • http://www.rosscode.com/ Joel Ross

    The best refactoring I’ve ever been a part of was upgrading a rather large project from .NET 1.1 to .NET 2.0. Just being able to get rid of our custom typed collections and move to generics saved us 200,000 lines of code. All in all, by taking advantage of other 2.0 features, such as master pages, we ended up cutting 250,000 lines of code.

    And you know what? The code is much more maintainable now. We’re able to make changes much more rapidly then we were in the past, which is probably the biggest measure of success for me.

  • http://simpable.com/ Scott Watermasysk

    > One of my favorite things to do is not to write additional code, but to remove code, either because it’s no longer needed or by way of refactoring. Nothing makes me happier than shrinking a codebase.

    You are a blast at parties. :)

    I guess I am no fun either since I agree. I really like the idea of removing 2 lines of code before you add another new line of code.

    Now, I have an idea for HAT III.

  • http://blog.lozanotek.com/ Javier Lozano

    Love it… Here’s more:

    “Perfection is not when there is no more to add, but no more to take away.”
    - Antione de Saint Exupéry

    “It is vain to do more with what can be done with less.”
    - William of Occam

  • http://www.arcware.net/ Dave

    Javier – Great quotes, thanks.

  • Jamison Roberts

    Generally I agree, but I’ve seen where the zeal to “do things in less code” makes the code base harder to understand and maintain. The problem really rears it’s ugly head in languages like Perl and Ruby, though you can create some ugly method chaining in .Net too.

    A great example is nested ternary operators, or even ternary operations where you don’t actually need one. Though of course people that do those sorts of things probably don’t realize what’s going on under the hood. But hey, they did it in less lines of code.

  • http://www.understandingguitar.org/ Frank

    Quite simply, I agree!

    Also, very well put.

  • http://www.loudcarrot.com/ jennifer

    Same goes for writing… the more words doesn’t mean the better writing, etc. EB White has a book on this–Elements of Style
    If u ever have a chance to write something similar for coding, you should. Although I imagine it’s probably out there somewhere.