arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2109.04256cs.SE
收藏

软件系统中依赖注入反模式的编目

Cataloging Dependency Injection Anti-Patterns in Software Systems

Rodrigo Laigner, Diogo Mendonça, Alessandro Garcia, Marcos Kalinowski

摘要:

内容:依赖注入(DI)是一种常用的机制,用于将类与其依赖项解耦,以提供更高的模块化。然而,糟糕的DI实践通常会导致负面后果,比如增加耦合。虽然白色文献中提到了DI反模式的存在,但没有证据表明它们的实际相关性、有用性和普遍性。目的:本研究的目的是提出和评估Java DI反模式和相关重构的目录。方法:我们回顾了现有的DI反模式,以分析其完整性。在文献中发现的局限性促使提出了一个新的12个DI反模式目录。我们开发了一个工具来静态分析候选DI反模式在开源和行业项目中的出现级别。接下来,我们调查从业者,以评估他们对相关性、有用性的看法,以及他们重构目录的反模式实例的意愿。结果:我们的静态代码分析工具显示出92.19%的相对召回率和较高的平均精度。结果表明,至少有9种不同的DI反模式在分析的项目中频繁出现。此外,我们的调查证实了目录的感知相关性,开发人员表示愿意从源代码重构反模式的实例。结论:该目录包含实践中出现的Java DI反模式,这些反模式被认为是有用的。与实践者分享它可以帮助他们避免这种反模式,从而提高源代码质量。

英文摘要:

Context: Dependency Injection (DI) is a commonly applied mechanism to decouple classes from their dependencies in order to provide higher modularization. However, bad DI practices often lead to negative consequences, such as increasing coupling. Although white literature conjectures about the existence of DI anti-patterns, there is no evidence on their practical relevance, usefulness, and generality. Objective: The objective of this study is to propose and evaluate a catalog of Java DI anti-patterns and associated refactorings. Methodology: We reviewed existing reported DI anti-patterns in order to analyze their completeness. The limitations found in literature motivated proposing a novel catalog of 12 DI anti-patterns. We developed a tool to statically analyze the occurrence level of the candidate DI anti-patterns in both open-source and industry projects. Next, we survey practitioners to assess their perception on the relevance, usefulness, and their willingness on refactoring anti-pattern instances of the catalog. Results: Our static code analyzer tool showed a relative recall of 92.19% and high average precision. It revealed that at least 9 different DI anti-patterns appeared frequently in the analyzed projects. Besides, our survey confirmed the perceived relevance of the catalog and developers expressed their willingness to refactor instances of anti-patterns from source code. Conclusion: The catalog contains Java DI anti-patterns that occur in practice and that are perceived as useful. Sharing it with practitioners may help them to avoid such anti-patterns, thus improving source-code quality.

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

↑