What’s that smell? Bad Code?

To determine whether a piece of source code is of good quality most of the time the first thought is: “I would have done this completely differently. ” We call this the “Not Invented Here” syndrome and can be very destructive to your product or project. Kent Beck introduced the term “Code Smell” to indicate obvious flaws in software. Most of the time Bad Code Smell is a precursor to much larger underlying problems that will eventually surface leaving the company with not enough time to fix them. Granted the term “smell” can still be very subjective: a much more objective way to look at source code metrics to determine the source code. Using these metrics in combination with a “smell report” would enable you to draw a conclusion about the source quality: is it well coded or the work of code monkeys. The next blog post I found a good argument to pay special attention to a single code metric: the CycloMatic Complexity. Cyclomatic Complexity can indicate too many scenario’s of a single method. It depicts the ideal number of different unit tests needed to cover all paths. Having a high complexity makes the code hard to test, thus smell bad. This indicates how difficult the code is to test either by unittest or manually, this has a direct relation to the maintainability of the code. Very interesting. Build systems for Java like the Maven PMD plugin support this metric.