| 研究生: |
林均儕 Lin, Jun-Chai |
|---|---|
| 論文名稱: |
基於CKJM-DI 指標分析依賴注入實現方式對軟體可維護性的影響 Impact of Dependency Injection on Software Maintainability Based on CKJM-DI |
| 指導教授: |
廖峻鋒
許志堅 |
| 口試委員: | 馬尚彬 |
| 學位類別: |
碩士
Master |
| 系所名稱: |
傳播學院 - 數位內容碩士學位學程 Digital Content and Technologies |
| 論文出版年: | 2025 |
| 畢業學年度: | 113 |
| 語文別: | 中文 |
| 論文頁數: | 63 |
| 中文關鍵詞: | 依賴注入 、軟體品質指標 、可維護性 |
| 相關次數: | 點閱:143 下載:0 |
| 分享至: |
| 查詢本校圖書館目錄 查詢臺灣博碩士論文知識加值系統 勘誤回報 |
隨著資訊技術的快速發展,軟體系統架構也變得日益複雜。程式碼量的增 加以及模組間的緊密耦合,讓軟體架構的維護與擴展變得更加困難。為了解決 這些挑戰,控制反轉(Inversion of Control, IoC)技術應運而生。IoC 的核心理 念是將物件的控制權從內部轉交給外部框架來管理,以減少模組間的依賴關係 並提升架構的靈活性。其中,依賴注入(Dependency Injection, DI)作為 IoC 的 主要實踐方式,通過外部實體動態提供物件所需的依賴,使物件無需直接管理 這些依賴,從而降低模組耦合度,並促進軟體架構的模組化設計。而 Spring Framework 即是目前業界最廣泛使用的 Java 依賴注入框架。
然而,依賴注入雖然提升了軟體架構的靈活性與可維護性,但其不當使用 可能引發一系列反模式(Anti-Pattern)。例如,過度依賴注入可能導致耦合度增 加,或將依賴隱藏於框架內部,使得對 DI 框架(如 Spring Framework)理解不 足的開發者面臨更高的維護成本,進而累積技術債。
軟體品質始終是開發社群關注的重要議題,而具備良好可維護性與可測試 性的架構設計,是開發者追求的目標之一。儘管軟體品質的定義已相對清晰, 但衡量這些品質的工具卻十分有限。因此,本研究開發出軟體品質指標計算工 具 CKJM-DI 及 XML-DI,用以量化軟體品質指標,並藉指標數值比較使用與未 使用依賴注入,以及不同依賴注入實現方式對軟體可維護性的影響。
本研究透過實驗進行了對指標數據的分析,驗證出使用依賴注入相較於不 使用依賴注入時更可以提升軟體可維護性,也提供了三種不同依賴注入實現方 式各自的好處與影響供開發人員做選擇。最後,也將 CKJM-DI 與 CKJM 原版相 比,證明了 CKJM-DI 更適合應用於依賴注入場景。
謝辭 ii
摘要 iii
目錄 iv
圖目錄 vi
表目錄 viii
第一章 緒論 1
第一節 研究背景與動機 1
第二節 研究目的與問題 5
第三節 預期貢獻和研究流程 6
第二章 技術背景與文獻探討 8
第一節 依賴注入(Dependency Injection) 8
第二節 Bean 的配置方式與注入方式 12
第三節 依賴注入的反模式(Anti-Pattern) 18
第四節 XML 可維護性的量化指標 19
第五節 相關研究 19
第三章 系統設計 21
第一節 發展適用於依賴注入的可維護性量化指標 21
第二節 發展適用於 XML 的可維護性量化指標 25
第三節 發展指標測試基準(Benchmark) 28
第四章 評估與討論 35
第一節 以 CKJM-DI 分析使用依賴注入前後影響 35
第二節 以 CKJM-DI、XML-DI 分析依賴注入不同實現方式 44
第三節 評估 CKJM-DI 與 CKJM-Original 差異 49
第四節 研究問題討論 56
第五章 結論 59
參考文獻 61
[1] Spinellis, D. (2005). Tool writing: A forgotten art? IEEE Software, 22(4), 9–11. https://doi.org/10.1109/MS.2005.111
[2] Chidamber, S. R., & Kemerer, C. F. (1994). A metrics suite for object-oriented design. IEEE Transactions on Software Engineering, 20(6), 476–493. https://doi.org/10.1109/32.295895
[3] Fowler, M. (2004, January 23). Inversion of control containers and the dependency injection pattern. Martin Fowler. https://www.martinfowler.com/articles/injection.html
[4] Sobernig, S., & Zdun, U. (2010, July). Inversion-of-Control layer. In Proceedings of the 15th European Conference on Pattern Languages of Programs (EuroPLoP), Irsee, Bavaria, Germany. Association for Computing Machinery. https://doi.org/10.1145/2328909.2328935
[5] Roubtsov, S., Serebrenik, A., & van den Brand, M. (2010). Detecting modularity "smells" in dependencies injected with Java annotations. In Proceedings of the 14th European Conference on Software Maintenance and Reengineering (pp. 244-247). IEEE.
https://doi.org/10.1109/CSMR.2010.45
[6] Yang, H. Y., Tempero, E., & Melton, H. (2008). An empirical study into the use of dependency injection in Java. In 19th Australian Conference on Software Engineering (ASWEC), 239-247. IEEE.
https://doi.org/10.1109/ASWEC.2008.4483212
[7] R. C. Martin. The Dependency Inversion Principle. C++ Report, 8(6):61–66, June 1996.
[8] Chen, M., Tu, T., Zhang, H., Wen, Q., & Wang, W. (2022). Jasmine: A static analysis framework for Spring core technologies. In 37th IEEE/ACM International Conference on Automated Software Engineering (ASE), October 10-14, 2022, Rochester, MI, USA. ACM.
https://doi.org/10.1145/3551349.3556910
[9] Hundsdorfer, S., Elsner, D., & Pretschner, A. (2023). DIRTS: Dependency Injection Aware Regression Test Selection. In 2023 IEEE Conference on Software Testing, Verification and Validation (ICST), 422-432. IEEE. https://doi.org/10.1109/ICST57152.2023.00046
[10] Laigner, R., Kalinowski, M., Carvalho, L., Mendonça, D., & Garcia, A. (2019). Towards a catalog of Java dependency injection anti-patterns. In Proceedings of the XXXIII Brazilian Symposium on Software Engineering (SBES 2019), Salvador, Brazil (pp. 10 pages). Association for Computing Machinery. https://doi.org/10.1145/3350768.3350771
[11] Qureshi, M. H., & Samadzadeh, M. H. (2005). Determining the complexity of XML documents. Proceedings of the International Conference on Information Technology: Coding and Computing (ITCC’05). IEEE. https://doi.org/10.1109/ITCC.2005.126
[12] McDowell, A., Schmidt, C., & Yue, K. (2004). Analysis and metrics of XML Schema. In Proceedings of the 2004 International Conference on Software Engineering Research and Practice (pp. 538–544). Las Vegas, NV.
[13] Chawla, M. K., & Chhabra, I. (2015). SQMMA: Software Quality Model for Maintainability Analysis. Proceedings of Compute 2015, October 29-31, Ghaziabad, India. Association for Computing Machinery. https://doi.org/10.1145/2835043.2835062
[14] R. Nambiar, “Java petstore: A case study,” Ph.D. dissertation, Kansas State University, 2005.
[15] A. Shatnawi, H. Mili, G. El Boussaidi, A. Boubaker, Y.-G. Guéhéneuc, N. Moha, J. Privat, and M. Abdellatif, “Analyzing program dependencies in java ee applications,” in 2017 IEEE/ACM 14th International Conference on Mining Software Repositories (MSR). IEEE, 2017, pp. 64–74.
https://doi.org/10.1109/MSR.2017.6
[16] ISO. (2011). ISO/IEC 25010:2011. Systems and software engineering—Systems and software Quality Requirements and Evaluation (SQuaRE)—System and software quality models. International Organization for Standardization.
[17] Cai, Y., & Sullivan, K. (2006). Modularity analysis of logical design models. In 21st IEEE International Conference on Automated Software Engineering (ASE) (pp. 199–208). IEEE.
https://doi.org/10.1109/ASE.2006.53
[18] Sun, C.-W., & Liao, C.-F. (2023). Examining the influence of dependency injection on software maintainability. In Proceedings of the 8th IEEE International Conference on Big Data, Cloud Computing, and Data Science (BCD) (pp. 250–255). IEEE. https://doi.org/10.1109/BCD57833.2023.10466290
全文公開日期 2028/05/26