工业代码中断言的使用与缺陷
Assert Use and Defectiveness in Industrial Code
摘要:
在过去的几年里,断言在代码中的使用在软件工程社区中受到了越来越多的关注,尽管它几十年来一直是公认的编程构造。Casalnuovo之前的一项实证研究表明,包含断言的方法比不包含断言的方法缺陷更少。在本文中,我们分析了两个工业电信Java系统的测试类,以支持或反驳这一发现。我们还分析了断言在方法中的物理位置,以确定断言放置和方法缺陷倾向之间是否存在关系。最后,我们探讨了测试方法大小的作用及其与断言的关系。就Casalnuovo之前的研究而言,我们只发现了有限的证据来支持早期的结果。然而,我们确实发现,具有一个断言的有缺陷的方法往往比无缺陷的方法位于类的位置上的级别要低得多。最后,方法大小似乎与断言有很强的相关性,但令人惊讶的是,当我们排除只有一个断言的方法时,这种相关性就不那么强了。所描述的工作强调了对代码的这一方面进行更多研究的必要性,这与代码理解有很强的联系。
英文摘要:
The use of asserts in code has received increasing attention in the software engineering community in the past few years, even though it has been a recognized programming construct for many decades. A previous empirical study by Casalnuovo showed that methods containing asserts had fewer defects than those that did not. In this paper, we analyze the test classes of two industrial telecom Java systems to lend support to, or refute that finding. We also analyze the physical position of asserts in methods to determine if there is a relationship between assert placement and method defect-proneness. Finally, we explore the role of test method size and the relationship it has with asserts. In terms of the previous study by Casalnuovo, we found only limited evidence to support the earlier results. We did however find that defective methods with one assert tended to be located at significantly lower levels of the class position-wise than non-defective methods. Finally, method size seemed to correlate strongly with asserts, but surprisingly less so when we excluded methods with just one assert. The work described highlights the need for more studies into this aspect of code, one which has strong links with code comprehension.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。