A new study conducted by researchers in Sri Lanka has reached a startling conclusion: refactoring code doesn’t improve its quality. The report, titled “An Empirical Evaluation of Impact of Refactoring On Internal and External Measures of Code Quality,” applied common refactoring techniques to a small application. They then analyzed both the original and the refactored code using the Maintainability Index, Cyclomatic Complexity, Depth of Inheritance, Class Coupling, and Line of Code metrics in Visual Studio. They also asked computer science students to evaluate both versions.
The study found that the refactored code scored lower for analyzability, made bug fixes take longer and ran slower, although none of those difference were statistically significant. It also found no evidence that the refactored code consumed less memory than the original. The refactored code did score slightly higher on the Maintainability Index, but the difference was slight.