SLOC: the worst metric

From Dennis Forbes - Pragmatic Software Development : Process, People, Programming

SLOC, if you haven’t been afflicted with it, is an easily computed count of the number of lines of code in a given project/component/object

He goes on to say that a large amount of lines of source generally means that the code bad condition.  I totally agree. I can’t tell you how often I’ve seen a horrid pile of code that was copied and pasted over and over again — simply because the original programmer didn’t stop and think about what he or she was doing.  And then, later, another developer stepped in and needed to add some similar functionality and, instead of making a method from the horrible heap they needed to duplicate, they just copied and pasted it, and made few new method calls in the middle.  A couple of times, they even left in the mis-spelled method names.

If this had happened just a few times, I may be able to forgive it.  But I see it over and over and over again in the projects I have inherited.  Recently, I took the code that I was working with that had this cut-and-paste pattern in it and wrapped some logic in it’s own method which made the code one fourth as big as it was before.  And it was clearer and easier to change.

So, by making the code better, I  would have inherited an SVGA monitor.  Well, so be it.

Leave a Reply

You must be logged in to post a comment.