There are possible benefits and drawbacks to chaining methods together, as is often done in fluent APIs. A prior study investigated how Java developers chain methods in over 2.7k open-source projects. That study observed, for the dataset analyzed, that the use of method chaining in Java is popular and seems to be increasing over time. That study however was limited to a smaller sample of Java projects, and it is also not clear if the results generalize to other languages. In this work, we first replicate the prior results by building a similar dataset and our own analysis scripts. We then extend those results by analyzing a much larger dataset of 89k Java projects and generalizing to other programming languages by analyzing 26k Kotlin projects and 98k Python projects. The results show chaining is more popular in Java and Kotlin than Python, chaining use in Kotlin is not growing, and Python sees more use in non-testing code.
翻译:----
方法链将方法链接在一起可能存在优点和缺点,这通常在流畅的API中使用。先前的研究调查了Java开发人员在超过2.7k个开源项目中如何链接方法。对于所分析的数据集,该研究观察到,在Java中使用方法链接很流行,并且似乎随时间推移而增加。但是,该研究仅限于较小的Java项目样本,并且不清楚结果是否可以推广到其他语言。在这项工作中,我们首先通过构建类似的数据集和我们自己的分析脚本来复制先前的结果。然后,我们通过分析89k个Java项目的更大数据集并通过分析26k个Kotlin项目和98k个Python项目来推广到其他编程语言。结果显示,在Java和Kotlin中更受欢迎,并且不断增长,而Kotlin中的链接使用并未增长,Python在非测试代码中的使用更多。