Software Refactoring Workbook: Measuring "Smells"
- Smells Covered
- Long Method
- Large Class
- Long Parameter List
- More Challenges
The smells in this chapter are similar. They're dead easy to detect. They're objective (once you decide on a way to count and a maximum acceptable score). They're odious.
And, they're common.
You can think of these smells as being caught by a software metric. Each metric tends to catch different aspects of why code isn't as good as it could be. Some metrics measure variants of code length; others try to measure the connections between methods or objects; others measure a distance from an ideal.
Most metrics seem to correlate with length, so I tend to worry about size first (usually noticeable as a Large Class or Long Method). But if a metric is easy to compute, I'll use it as an indicator that some section of code deserves a closer look.
Metrics are indicators, not absolutes. It's very easy to get into the trap of making numbers without addressing the total complexity. So don't refactor just for a better number; make sure it really improves your code.
Long Parameter List