Mining the Use of Higher-Order Functions: An Exploratory Study on Scala Programs

Published in Proceedings of the National Software Application Conference (NASAC 2019), Hangzhou, China. 2019., 2019

In this paper, we investigate the use of higher-order functions in Scala programs. We collected 7,804 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 definitions and calls, the overlap with lambda expressions, the developer contribution, and the factor that affects the function calls. Our study mainly shows five empirical results about the common use of higher-order functions in Scala programs: higher-order functions are not widely used in Scala programs; most of higher-order functions are defined and called by the same developers; there exists a small overlap between calling higher-order functions and calling lambda expressions; top 20% of developers have contributed 81% of definitions and 86% of calls of higher-order functions; and the number of calls of higher-order functions correlates most with the number of executable lines of code and the code complexity. This study can be viewed as a preliminary result to understand the use of higher-order functions and to trigger further investigation in Scala programs.

Writing Tests for This Higher-Order Function First Automatically Identifying Future Callings to Assist Testers

Published in Proceedings of the 11th Asia-Pacific Symposium on Internetware (Internetware ’19), October 28–29, 2019, Fukuoka, Japan., 2019

In this paper, we propose an automatic approach, namely Phof, which predicts whether a higher-order function will be called in the future. Higher- order functions that are most likely to be called should be tested first. Our approach can assist developers to reduce the number of higher- order functions under test. In Phof, we extracted 24 features from source code and logs to train a predictive model based on known higher-order functions calls. We empirically evaluated our approach on 2854 higher-order functions from six real-world Scala projects. Experimental results show that Phof based on the random forest algorithm and the SMOTE strategy performs well in the prediction of calls of higher-order functions. Our work can be used to support the scheduling of limited test resources.