Minimizing LOC as a metric


Posted by Steven

Since reading the biography of Steve Jobs, I more and more do agree with the idea of minimalization. Obviously, he had huge success by simply leaving out things and concentrating on the rest. In recent months it became clear to me that this also applies to software development.

The metric of Lines Of Code (LOC) sure is the oldest code-metric and often is perceived as "not so significant" because metrics like the cyclomatic complexity are around. But in combination with the concept of minimalization, one could define a new metric: "less LOC". In the understanding of this new metric, one codebase is superior over another if it

  1. Passes the same Unit Tests and
  2. Has the same or less amount of checkstyle-warnings and
  3. Has less LOC.

What does that mean for the developer? Simply write less code. Leave comments out. Leave not-used access-methods out. Erase whitespace lines.

One could think that metric means "more inline declarations" and heavy chaining of method-calls in one line. That assumption would hold true with the definition given above. Checkstyle should take care of one-line methods where this one line has a thousand characters and I hope that the common sense of the developer takes care of the "allowed" shortcuts. Code has to be maintainable, not as short it can possibly get.

Category: 
Share: