Examining the Influence of Dependency Injection on Software Maintainability

Chun-Wei Sun, Chun-Feng Liao · 2023

Dependency Injection (DI) is a widely adopted design pattern in the software industry. DI reduces the otherwise necessary coupling between a client and the concrete object providing the service. This decoupling is achieved by delegating the responsibility of object creation to an external DI module, commonly referred to as a DI Container. Nevertheless, DI can introduce certain side effects. To guide the external DI module on the wiring logic, developers must either detail these logics in configuration files or use language constructs specific to the DI implementation in use. In large-scale projects, managing these wiring logics can pose a significant challenge to software maintainability. Currently, the Spring Framework stands as one of the most prominent DI implementations. It provides three methods for describing the wiring logic: XML, Annotation, and Java Class. This paper delves into the effects of these three methods on software maintainability, their influence on software design, and the optimal circumstances for each method’s use in managing wiring logic. Our study examines the issues aforementioned using the well-known web application benchmark, JPetStore. We adapt the benchmark application’s source code through different wiring logic implementations and evaluate the resultant effects on software coupling metrics. Finally, we explore the implications of these modifications on software coupling and maintainability.

Read the paper · More papers on PaperTik