arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2602.12950cs.SE
收藏

代码异味在传出邻居中的影响对类稳定性的作用

The Influence of Code Smells in Efferent Neighbors on Class Stability

University of Auckland(奥克兰大学)

Zushuai Zhang, Elliott Wen, Ewan Tempero

AI总结:

本研究探讨了代码异味在传出邻居中的影响对类稳定性的作用,考虑了代码异味的互相关和相互作用因素。

摘要:

理解驱动代码不稳定性的因素对于有效的软件维护至关重要,因为不稳定的类需要更多的编辑或更频繁的修改,并增加意外副作用的风险。尽管代码异味被广泛认为会损害可维护性,但大多数先前的稳定性研究仅研究被修改类内部的异味。然而,在实践中,类的变化可能是因为它们依赖的传出邻居(即依赖的类)被修改,这种变化可能通过静态依赖关系传播,即使该类本身是干净的。此类涟漪效应可能在传出邻居存在代码异味时更加严重。此外,代码异味很少单独出现。它们通常出现在同一类或通过静态依赖关系连接的类中,这种现象称为代码异味互相关。这种互相关可能导致代码异味相互作用,其中异味通过静态依赖关系直接连接,并可能进一步加剧可维护性问题。然而,代码异味互相关和相互作用对代码质量的影响仍然鲜为人知。因此,本研究探讨了类的传出邻居中存在代码异味是否会影响其稳定性,考虑了代码异味互相关和相互作用的因素。为此,我们从100个顶级GitHub项目的一年的提交历史中挖掘数据,检测代码异味和静态依赖关系,确定代码异味互相关和相互作用,并将这些因素作为类稳定性的预测变量进行建模。

英文摘要:

Understanding what drives code instability is essential for effective software maintenance, as unstable classes require larger or more frequent edits and increase the risk of unintended side effects. Although code smells are widely believed to harm maintainability, most prior stability studies examine only the smells within the class being modified. In practice, however, a class can change because its efferent neighbors (i.e., the classes it depends on) are modified due to ripple effects that propagate along static dependencies, even if the class itself is clean. Such ripple effects may be more severe when efferent neighbors exhibit code smells. Therefore, this study investigates whether code smells in a class's efferent neighbors affect its stability. We mined one year of commit history from 152 top-starred GitHub Java projects, detected code smells and static dependencies, and modeled their associations with class stability. Our results challenge the practice of examining code smells only within the class being maintained by showing that this provides an incomplete view of stability risk. Specifically, considering code smells in efferent neighbors reveals stability risks that are not observed when examining code smells in the class itself. Moreover, considering smells in both the class and its efferent neighbors, as well as their relationships across dependencies, reveals further stability risks that are not observed when smells at these two locations are analyzed separately. Consequently, these findings suggest that code smell analysis for class maintenance should extend beyond the class being maintained to the classes on which it depends.

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

↑