The Good, the Bad, and the Monstrous: Predicting Highly Change-Prone Source Code Methods at Their Inception

Shaiful Chowdhury
2024-12-30
Abstract:The cost of software maintenance often surpasses the initial development expenses, making it a significant concern for the software industry. A key strategy for alleviating future maintenance burdens is the early prediction and identification of change-prone code components, which allows for timely optimizations. While prior research has largely concentrated on predicting change-prone files and classes, an approach less favored by practitioners, this paper shifts focus to predicting highly change-prone methods, aligning with the preferences of both practitioners and researchers. We analyzed 774,051 source code methods from 49 prominent open-source Java projects. Our findings reveal that approximately 80% of changes are concentrated in just 20% of the methods, demonstrating the Pareto 80/20 principle. Moreover, this subset of methods is responsible for the majority of the identified bugs in these projects. After establishing their critical role in mitigating software maintenance costs, our study shows that machine learning models can effectively identify these highly change-prone methods from their inception. Additionally, we conducted a thorough manual analysis to uncover common patterns (or concepts) among the more difficult-to-predict methods. These insights can help future research develop new features and enhance prediction accuracy.
Software Engineering
What problem does this paper attempt to address?
### What problems does this paper attempt to solve? This paper mainly focuses on the problem of excessive software maintenance costs. In particular, it aims to reduce future maintenance burdens through early prediction and identification of change - prone code components. Specifically, the author shifts the research focus from predicting change - prone files and classes (these methods are not very popular in practice) to predicting highly change - prone methods, in order to better meet the needs of practitioners and researchers. #### Main problems and goals 1. **Excessive software maintenance costs**: - Software maintenance costs usually exceed the initial development costs and may even account for 90% of the total cost of ownership. - Therefore, research on reducing future maintenance burdens is crucial. 2. **Predicting change - prone code components**: - Change - proneness and bug - proneness are two important indicators for evaluating future software maintenance costs and workloads. - Early prediction and improvement of these change - prone or bug - prone code components can significantly reduce future maintenance burdens. 3. **Limitations of existing research**: - Most existing research focuses on class - level prediction, which is very difficult, time - consuming and inefficient for practitioners to manage in practical applications. - Method - level prediction is more refined and helps to more accurately locate the parts of the code that need maintenance. 4. **New research focus**: - This paper focuses on method - level change - proneness prediction, using a data set of 774,051 Java methods to analyze the change history of these methods. - The research finds that approximately 80% of the changes are concentrated in 20% of the methods, verifying the Pareto 80/20 principle. - These highly change - prone methods are also responsible for most of the errors in the project. #### Core research questions 1. **RQ1: Does method - level change - proneness follow the Pareto 80/20 principle?** - Conclusion: In most projects, about 80% of the changes come from 20% of the methods, which are called "monstrous" methods. 2. **RQ2: What percentage of errors can be detected by capturing "monstrous" methods?** - Conclusion: Capturing the top 20% of change - prone methods can detect up to 80% of the errors, indicating that the change prediction model can also effectively identify error - prone methods. 3. **RQ3: Can we use machine - learning models to accurately predict "monstrous" methods when the methods are created?** - Conclusion: A single code metric (such as size or complexity) is not sufficient to capture "monstrous" methods. But by using 17 related predictors (such as size, complexity, readability, fan - out, etc.), various machine - learning models can make effective predictions when the methods are created. 4. **RQ4: When can machine - learning models not detect "monstrous" methods?** - Conclusion: Although the overall prediction accuracy of the model is encouraging (for example, the precision is 75% and the recall is 80%), through qualitative analysis of 100 samples, several common patterns and features are found, which explain the reasons for some unexpected results. By solving these problems, this paper aims to provide a more effective early prediction method, help reduce future software maintenance costs, and improve software quality.