An empirical study of data constraint implementations in Java

An empirical study of data constraint implementations in Java
复制标题

DOI:
10.1007/s10664-022-10175-w
复制
发表时间:
2021-07
影响因子:
4.1
通讯作者:
Juan Manuel Florez;Laura Moreno;Zenong Zhang;Shiyi Wei;Andrian Marcus
Juan Manuel Florez;Laura Moreno;Zenong Zhang;Shiyi Wei;Andrian Marcus
中科院分区:
计算机科学2区
文献类型:
--
作者:
Juan Manuel Florez;Laura Moreno;Zenong Zhang;Shiyi Wei;Andrian Marcus

文献摘要

被引文献

相似文献

软件系统是根据业务规则定义的指导方针和约束来设计的。其中一些约束定义了系统处理的数据的允许值或必需值。这些数据约束通常源自问题域(例如,法规),开发人员必须编写执行这些法规的代码。了解数据约束是如何实现的对于测试、调试和软件更改是必不可少的。不幸的是,在如何实现数据约束方面没有广泛接受的指导方针或最佳实践。本文提出了一个实证研究,调查如何在Java中实现数据约束。我们研究了从8个真实世界的Java软件系统的文档中提取的187个数据约束的实现。首先,我们对数据约束的文本描述进行了定性分析,并确定了四种数据约束类型。其次,我们手动识别这些数据约束的实现,并揭示它们可以分为31个实现模式。对这些实现模式的分析表明,开发人员在实现数据约束时更喜欢少数模式。我们还发现了一些证据,表明偏离这些模式与不寻常的实现决策或代码气味有关。第三,我们开发了一个工具辅助协议,使我们能够确定256个额外的跟踪链接的数据约束,使用13个最常见的模式。我们发现,几乎一半的这些数据约束有多个强制语句,这是不同类型的代码克隆。最后,对16名专业开发人员的研究表明,我们描述的模式可以在Java代码中轻松准确地识别。
Software systems are designed according to guidelines and constraints defined by business rules. Some of these constraints define the allowable or required values for data handled by the systems. Thesedata constraintsusually originate from the problem domain (e.g., regulations), and developers must write code that enforces them. Understanding how data constraints are implemented is essential for testing, debugging, and software change. Unfortunately, there are no widely-accepted guidelines or best practices on how to implement data constraints. This paper presents an empirical study that investigates how data constraints are implemented in Java. We study the implementation of 187 data constraints extracted from the documentation of eight real-world Java software systems. First, we perform a qualitative analysis of the textual description of data constraints and identify four data constraint types. Second, we manually identify the implementations of these data constraints and reveal that they can be grouped into 31implementation patterns. The analysis of these implementation patterns indicates that developers prefer a handful of patterns when implementing data constraints. We also found evidence suggesting that deviations from these patterns are associated with unusual implementation decisions or code smells. Third, we develop a tool-assisted protocol that allows us to identify 256 additional trace links for the data constraints implemented using the 13 most common patterns. We find that almost half of these data constraints have multiple enforcing statements, which are code clones of different types. Finally, a study with 16 professional developers indicates that the patterns we describe can be easily and accurately recognized in Java code.