Hacker News new | past | comments | ask | show | jobs | submit login

This story is about how useless LOC is as a metric.

But negative LOC alone is just as useless a metric as positive LOC. It's easy to come up with examples where deleting unused code is actually harmful:

- Just delete all comments

- Remove platform code you are not using now, but might in the future

- Remove reference code because you are only using platform code

- Remove test code that is just not called yet, but really should be

- Remove code from a copied library that is now harder to keep current

- etc..




- Just delete all comments

This is definitely harmful, agreed.

- Remove platform code you are not using now, but might in the future

Definitely. It's in the repo if you want to get it back, so there's no reason why unused code should be in your source.

- Remove reference code because you are only using platform code

Yes. Remove everything you're not using. It's in the repo.

- Remove test code that is just not called yet, but really should be

And again. Remove it if it's not used. Or start using it. Nothing else is acceptable.

- Remove code from a copied library that is now harder to keep current

You should probably be pinning versions of libraries otherwise you're going to see things break in the future. Upgrading them is a feature.

Deleting comments aside, using negative LOC as a metric does encourage people to write better code.


Negative LOC while retaining those things would be optimal, if you can manage to reduce the size of the overall codebase while fixing issues and/or adding features it's the best possible outcome.


LOC is not useless since it's just a metric. It's interpretation is what matters.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: