Refactoring code to increase readability and maintainability: a case study

Christopher Dibble, Paul V. Gestwicki · Journal of computing sciences in colleges · 2014

We describe a case study in refactoring-improving a program's structure without changing its behavior. The program under analysis is an educational video game that was developed over five months by a cross- functional team of eleven. The implementation consists of 2823 lines of C# code across 111 source files. Although the team held themselves to high standards of software design early in their work, production pressures led to a decrease in software quality over time. The refactoring e?ort was undertaken by two team members one year after shipping the game. There were two forces driving the refactoring: the qualitative desire for increased use of object-oriented design patterns, and quantitative results of software metrics. Refactoring proceeded in two phases. First, JetBrains' ReSharper was used to identify potential issues, and its recommendations and autofix options were followed. Second, the researchers conducted a manual analysis of all source files to identify refactoring opportunites not identified by ReSharper; however, during this phase, ReSharper was used to track changes in metrics. Significant improvements in the code quality include a 2.35% increase in the maintainability index, 7.91% reduction in average cyclomatic complexity, and 10.4% reduction in average class coupling. Many existing code quality problems were reduced to zero, including compiler warnings, constraints violations, and redundancies in code. The refactoring did not significantly impact the performance of the game as measured in frames-per-second. This case study demonstrates how tool-mediated refactoring allows even a single developer to significantly impact the design of an existing software system. We also find that the automated refactorings suggested by ReSharper are primarily superficial and that refactoring to patterns requires more careful human analysis.

Read the paper · More papers on PaperTik