A aplicação da refatoração de código e suas consequências em um controlador de máquina agrícola - Zanchin, Douglas Maldaner (2025)
Refactoring aims to restructure software without altering its external behavior, seeking to make it more readable, modular, and maintainable. Therefore, this study investigated the effectiveness of code refactoring as a technique to reduce cyclomatic complexity and improve internal quality attributes, such as readability, clarity, and maintainability, in a legacy C# system. The research, conducted through a case study, involved refactoring selected code sections, applying established best practices. The changes were evaluated quantitatively, using metrics such as cyclomatic complexity and maintainability index, and qualitatively, through a questionnaire administered to a group of software developers. One of the quantitative results showed a 10.37% reduction in cyclomatic complexity while maintaining the maintainability index at 78, reflecting substantial gains in code readability, modularity, clarity, and organization. From a qualitative perspective, the results indicated a positive perception of refactoring, highlighting improved readability, clarity, organization, and code maintainability. However, the use of more abstract practices, such as polymorphism and LINQ, had variable acceptance, suggesting that the perception of refactoring depends on the team's technical level. Overall, the work demonstrated that refactoring contributed to: (i) reducing the structural complexity of the code, making it more readable and modular; (ii) increasing the maintainability index in critical classes, reflecting greater ease of future evolution; (iii) creating conditions for the introduction of unit tests, which were previously nonexistent; and (iv) strengthening the developers' positive perception of good development practices. These impacts highlight refactoring as an effective tool for the continuous improvement of software quality, contributing to the reduction of cyclomatic complexity and emphasizing the importance of regular refactoring practices throughout the software lifecycle.