Dependency injection (DI) is generally known to improve maintainability by keeping application classes separate from the library. Particularly within the Java environment, there are many applications using the principles of DI with the aim to improve maintainability. There exists some work that provides an inference on the impact of DI on maintainability, but no conclusive evidence is provided. The fact that there are no publicly available tools for quantifying DI makes such an evidence more difficult to be produced. In this paper, we propose a novel metric, DCBO, to measure the proportion of DI in a project based on weighted couplings. We describe how DCBO can serve as a more meaningful metric in computing maintainability when DI is also considered. The metric is implemented in the CKJM-Analyzer, an extension of the CKJM tool that utilizes static code analysis to detect DI. We discuss the algorithmic approach behind the static analysis and prove the soundness of the tool using a set of open-source Java projects.
翻译:众所周知,通过将应用类别与图书馆分开,依赖性注射(DI)可以提高可维持性。特别是在爪哇环境中,有许多应用应用应用DI原则,目的是提高可维持性。有些工作可以推断DI对可维持性的影响,但没有提供确凿证据。没有公开可用的工具来量化DI,这使得这种证据更难产生。在本文件中,我们建议采用新的标准DCBO, 以根据加权组合衡量项目中的DI比例。我们描述了DCBO如何在考虑DI时作为计算可维持性方面更有意义的衡量标准。该衡量标准在CKJM-Analyzer得到实施,这是利用静态代码分析探测DI的CKJM工具的延伸。我们讨论了静态分析背后的算法方法,并用一套开放源的Java项目证明该工具的健全性。