当前位置: X-MOL 学术Empir. Software Eng. › 论文详情
Our official English website, www.x-mol.net, welcomes your feedback! (Note: you will need to create a separate account there.)
Mining the use of higher-order functions:
Empirical Software Engineering ( IF 3.5 ) Pub Date : 2020-09-04 , DOI: 10.1007/s10664-020-09842-7
Yisen Xu , Fan Wu , Xiangyang Jia , Lingbo Li , Jifeng Xuan

A higher-order function takes one or more functions as inputs or outputs to support the generality of function definitions. In modern programming languages, higher-order functions are designed as a feature to enhance usability and scalability. Abstracting higher-order functions from existing functions decreases the number of similar functions and improves the code reuse. However, due to the complexity, defining and calling higher-order functions are not widely used in practice. In this paper, we investigate the use of higher-order functions in Scala programs. We collected 8,285 higher-order functions from 35 Scala projects in GitHub with the most stars and conducted an exploratory study via answering five research questions of using higher-order functions, including the data scale, the definition types, the definition distribution, the factor that correlates with the function calls, and the developer contribution. Our study mainly shows five empirical results about the common use of higher-order functions in Scala programs. Our findings are listed as follows. (1) Among 35 Scala projects, 6.84% of functions are defined as higher-order functions on average and the average calls per function show that higher-order functions are called more frequently than first-order functions. (2) In all higher-order functions in the study, 87.35% of definitions of higher-order functions and 90.66% of calls belong to the type that only takes functions as parameters. (3) Three measurements (including lines of executable code, Cyclomatic complexity, and warnings in the code style) in higher-order functions are lower than those of first-order functions. (4) Regression analysis on all projects suggests that the number of calling higher-order functions highly correlates with the Cyclomatic complexity. (5) In all projects in the study, 43.82% calls of higher-order functions are written by the same developers who have defined the functions and results show that top 20% authors of higher-order functions favor defining or calling higher-order functions than first-order functions. This study can be viewed as a preliminary result to understand the use of higher-order functions and to motivate further investigation in Scala programs.

中文翻译:

挖掘高阶函数的使用:

高阶函数将一个或多个函数作为输入或输出,以支持函数定义的通用性。在现代编程语言中,高阶函数被设计为增强可用性和可扩展性的功能。从现有函数中抽象出高阶函数减少了相似函数的数量并提高了代码重用性。然而,由于复杂性,定义和调用高阶函数在实践中并未得到广泛应用。在本文中,我们研究了高阶函数在 Scala 程序中的使用。我们从 GitHub 上 35 个 star 最多的 Scala 项目中收集了 8,285 个高阶函数,并通过回答使用高阶函数的五个研究问题进行了探索性研究,包括数据规模、定义类型、定义分布、与函数调用和开发人员贡献相关的因素。我们的研究主要展示了关于高阶函数在 Scala 程序中的常见使用的五个实证结果。我们的发现如下。(1) 在 35 个 Scala 项目中,平均 6.84% 的函数被定义为高阶函数,每个函数的平均调用次数表明,高阶函数比一阶函数被调用的频率更高。(2) 在研究的所有高阶函数中,87.35%的高阶函数定义和90.66%的调用属于仅以函数为参数的类型。(3) 高阶函数的三个度量(包括可执行代码行数、圈复杂度和代码风格的警告)低于一阶函数。(4) 对所有项目的回归分析表明,调用高阶函数的数量与圈复杂度高度相关。(5) 在研究的所有项目中,43.82% 的高阶函数调用是由定义函数的同一位开发人员编写的,结果表明,前 20% 的高阶函数作者倾向于定义或调用高阶函数比一阶函数。这项研究可以看作是理解高阶函数的使用并激发在 Scala 程序中进行进一步研究的初步结果。82% 的高阶函数调用是由定义函数的同一位开发人员编写的,结果表明,前 20% 的高阶函数作者更喜欢定义或调用高阶函数,而不是一阶函数。这项研究可以看作是理解高阶函数的使用并激发在 Scala 程序中进行进一步研究的初步结果。82% 的高阶函数调用是由定义函数的同一位开发人员编写的,结果表明,前 20% 的高阶函数作者更喜欢定义或调用高阶函数,而不是一阶函数。这项研究可以看作是理解高阶函数的使用并激发在 Scala 程序中进行进一步研究的初步结果。
更新日期:2020-09-04
down
wechat
bug