论文标题
开发人员如何提取功能:实验
How Developers Extract Functions: An Experiment
论文作者
论文摘要
创建功能是编写计算机程序的中心。但是,关于如何完成的经验研究几乎没有经验研究,开发人员使用了什么考虑。我们设计了一个实验,可以比较在完全相同的条件下多个开发人员做出的决策。该实验基于采用现有的生产代码,将其“将”“弄平”到单个单片功能中,然后向开发人员收取重构的任务,以通过提取功能来实现更好的设计。结果表明,开发人员倾向于根据结构提示提取功能,例如“ if”或“ try”块。尽管不同开发人员执行的重构之间存在显着相关性,但重构的大小也存在显着差异。例如,提取的功能数量在3到10之间,而提取到功能的代码量范围为37%至95%。
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%.