I also think the readability argument is overused. I definitely value readability, but I rarely see aggressive code re-use lead to significant-enough readability challenges to warrant not doing it. More often the before/after are both pretty readable, and the after has half as many possible test-cases.
[Edit (almost immediately): Nevermind. I don't think anything I said is in conflict with anything you said. I probably ought to take the approach I have to code and apply it to commenting.]
- If I debug this code, will there be meaningful intermediate values? (One clever line of code might lack those)
- Can a less experiences developer understand what this does?
My rationales:
- More SLOC means more places for a bug to hide.
- More SLOC means more logic to have to reason about.
- More repetition leads to more SLOC.
- More repetition increases the chance that a bug can be fixed in one spot but not in others.
- More repetition increases the chance for regression bugs resulting from updates not being fully propagated
Anecdotally, on my team it seems that we tend to have the least quality issues in the stuff that's written by folks who produce the most factored code.
- Fewer SLOC means more code fits on one page.
- Fewer SLOC means it may be easier to explain/document/remember what it does.
Having a high sloc number isn't necessarily good. Nor is having a low one.
Coding for readability and performance often results in fewer lines of code, but that's not a two-way street; coding specifically in order to reduce sloc doesn't magically make your code quicker or more readable.