Code smells smell
By pascal on Tuesday, July 17 2012, 12:38 - Permalink
This blog post is on the subject of “code smells” and what is wrong with them. I initially wanted to go with the title “Code smells are crap”. That made it clearer that the title was grammatically a sentence, with “code smells” a nominal group followed by a verb. But there seems to be something in this blog's content management system that censors four-letter words in the title of articles, like some sort of
administrator or something friendly moderator.
At the time of this writing, Wikipedia defines a code smell as “any symptom in the source code of a program that possibly indicates a deeper problem”. I do not challenge this definition. Indeed, to the best of my knowledge this is exactly the meaning many researchers (and engineers) working in software engineering intend when they talk of “code smells”. I think, however, that there is something fundamentally wrong, not with the definition, but with scientific use of any notion accurately described by this definition. The issue I see, in so many words, is that it is not falsifiable.
Say that you build a tool that detects “code smells”. You might even call your tool a “static analyzer”, and there might be so many of you and of your tools that “static analysis” is understood by the majority as the craft of building code smell detectors. The tool flags as smelly a diligent implementation of a subtle but efficient computation taken from The Art of Computer Programming. This deserves the name “false positive”, right? Surely your tool does not pretend to judge Knuth's carefully crafted, state-of-the-art algorithms? Ah, but no, it is not a false positive, because the notion is built right in the definition that a code smell only “possibly indicates a deeper problem”. Whatever the tool found is a code smell by virtue of having been flagged by the tool. It was not a problem, but it was a code smell because it could have indicated a problem.
As scientists, what the four-letter word are we supposed to do with such a notion?