arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2401.14244cs.SEcs.LOcs.PL
收藏

Android移动应用中契约的使用与演化

Contract Usage and Evolution in Android Mobile Applications

David R. Ferreira, Alexandra Mendes, João F. Ferreira

AI总结:

本文首次对Android应用中契约的使用与演化进行大规模实证研究,分析2,390个F-Droid应用,揭示契约采用率低、注解方式最流行、方法增长快于契约增长以及规范稳定性不足等问题,并提出标准化库与检测工具的建议。

摘要:

形式化契约与断言是通过强制前置条件、后置条件和不变量来提升软件质量的有效方法。先前的研究已经证明了契约在传统软件开发环境中的价值。然而,契约在移动应用开发环境——尤其是Android应用——中的采用情况与影响仍未得到探索。为解决这一问题,我们提出了首个针对使用Java或Kotlin编写的Android应用中契约存在与使用情况的大规模实证研究。我们将不同类型的契约元素划分为五个类别:条件运行时异常、API、注解、断言及其他。我们分析了来自F-Droid仓库的2,390个Android应用,并处理了超过51,749千行代码(KLOC),以确定:1)契约的使用方式与使用程度;2)契约使用如何演化;3)在程序演化和继承的背景下,契约是否被安全地使用。我们的发现包括:1)尽管大多数应用没有指定契约,但基于注解的方法在实践者中最受欢迎;2)使用契约的应用在后续版本中会继续使用它们,但方法数量的增长速度高于契约数量的增长速度;3)在应用演化过程中以及子类型关系中,存在许多潜在不安全的规范变更,这表明缺乏规范稳定性。我们的发现表明,有必要提供能够在Java和Kotlin中标准化契约规范的库,以及帮助实践者编写更强契约并在程序演化和继承背景下检测契约违规的工具。

英文摘要:

Formal contracts and assertions are effective methods to enhance software quality by enforcing preconditions, postconditions, and invariants. Previous research has demonstrated the value of contracts in traditional software development contexts. However, the adoption and impact of contracts in the context of mobile application development, particularly of Android applications, remain unexplored. To address this, we present the first large-scale empirical study on the presence and use of contracts in Android applications, written in Java or Kotlin. We consider different types of contract elements divided into five categories: conditional runtime exceptions, APIs, annotations, assertions, and other. We analyzed 2,390 Android applications from the F-Droid repository and processed more than 51,749 KLOC to determine 1) how and to what extent contracts are used, 2) how contract usage evolves, and 3) whether contracts are used safely in the context of program evolution and inheritance. Our findings include: 1) although most applications do not specify contracts, annotation-based approaches are the most popular among practitioners; 2) applications that use contracts continue to use them in later versions, but the number of methods increases at a higher rate than the number of contracts; and 3) there are many potentially unsafe specification changes when applications evolve and in subtyping relationships, which indicates a lack of specification stability. Our findings show that it would be desirable to have libraries that standardize contract specifications in Java and Kotlin, and tools that aid practitioners in writing stronger contracts and in detecting contract violations in the context of program evolution and inheritance.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑