When, if ever, is “number of lines of code” a useful metric?

后端 未结 30 2483
無奈伤痛
無奈伤痛 2020-12-08 09:32

Some people claim that code\'s worst enemy is its size, and I tend to agree. Yet every day you keep hearing things like

  • I write blah lines of code in a day.
相关标签:
30条回答
  • 2020-12-08 09:44

    It's a great metric for scaring/impressing people. That's about it, and definitely the context I'm seeing in all three of those examples.

    0 讨论(0)
  • 2020-12-08 09:44

    When you are refactoring a code base and can show that you removed lines of code, and all the regression tests still passed.

    0 讨论(0)
  • 2020-12-08 09:45

    The Software Engineering Institute's Process Maturity Profile of the Software Community: 1998 Year End Update (which I could not find a link to, unfortunately) discusses a survey of around 800 software development teams (or perhaps it was shops). The average defect density was 12 defects per 1000 LOC.

    If you had an application with 0 defects (it doesn't exist in reality, but let's suppose) and wrote 1000 LOC, on average, you can assume that you just introduced 12 defects into the system. If QA finds 1 or 2 defects and that's it, then they need to do more testing as there are probably 10+ more defects.

    0 讨论(0)
  • 2020-12-08 09:45

    Lines of code are useful to know when you're wondering if a code file is getting too large. Hmmm...This file is now 5000 lines of code. Maybe I should refactor this.

    0 讨论(0)
  • 2020-12-08 09:46

    There is one particular case when I find it invaluable. When you are in an interview and they tell you that part of your job will be to maintain an existing C++/Perl/Java/etc. legacy project. Asking the interviewer how many KLOC (approx.) are involved in the legacy project will give you a better idea as to whether you want their job or not.

    0 讨论(0)
  • 2020-12-08 09:47

    In competitions.

    0 讨论(0)
提交回复
热议问题