计算机科学 > 软件工程
[提交于 2022年9月5日]
标题:How Developers Extract Functions: An Experiment
查看原文 PDF 中文 PDF (下批处理) EasyResearch 阅读摘要:Creating functions is at the center of writing computer programs. But there has been little empirical research on how this is done and what are the considerations that developers use. We design an experiment in which we can compare the decisions made by multiple developers under exactly the same conditions. The experiment is based on taking existing production code, "flattening" it into a single monolithic function, and then charging developers with the task of refactoring it to achieve a better design by extracting functions. The results indicate that developers tend to extract functions based on structural cues, such as 'if' or 'try' blocks. And while there are significant correlations between the refactorings performed by different developers, there are also significant differences in the magnitude of refactoring done. For example, the number of functions that were extracted was between 3 and 10, and the amount of code extracted into functions ranged from 37% to 95%.
提交历史
来自:Dror Feitelson[v1] 2022年9月5日 星期一 00:00:00 UTC