返回
Supporting single responsibility through automated extract method refactoring
DOI:10.1007/s10664-023-10427-3.png)
摘要
En 中文
The responsibility of a method/function is to perform some desired computations and disseminate the results to its caller through various deliverables, including object fields and variables in output instructions. Based on this definition of responsibility, this paper offers a new algorithm to refactor long methods to those with a single responsibility. We propose a backward slicing algorithm to decompose a long method into slightly overlapping slices. The slices are computed for each output instruction, representing the outcome of a responsibility delegated to the method. The slices will be non-overlapping if the slicing criteria address the same output variable. The slices are further extracted as independent methods, invoked by the original method, if certain behavioral preservation are made. The proposed method has been evaluated on the GEMS extract method refactoring benchmark and three real-world projects. On average, our experiments demonstrate at least a 29.6% improvement in precision and a 12.1% improvement in the recall of uncovering refactoring opportunities compared to the state-of-the-art approaches. Furthermore, our tool improves method-level cohesion metrics by an average of 20% after refactoring. Experimental results confirm the applicability of the proposed approach in extracting methods with a single responsibility.
Keyword:
Extract method refactoring
Single responsibility
Program slicing
Long method
Output instructions
期刊
IF:
3.6
论文数:
2.0K
被引数:
5.3K
机构
引用论文
Analysis of genetic variability in various tissue culture-derived lemon plant populations using RAPD and flow cytometry
Euphytica
IF0
Research on the sliding friction associated spur-face gear meshing efficiency based on the loaded tooth contact analysis
PLOS ONE
IF0
Comparing and experimenting machine learning techniques for code smell detection比较和实验用于代码气味检测的机器学习技术
Re-Cloning the N27 Dopamine Cell Line to Improve a Cell Culture Model of Parkinson's Disease
PLOS ONE
IF0
Identification of extract method refactoring opportunities for the decomposition of methods识别方法分解的提取方法重构机会

