- Hands-On Dependency Injection in Go
- Corey Scott
- 162字
- 2021-06-10 19:17:49
What does this mean for Go?
We have talked before about Go's support for implicit interfaces and how we can leverage that to define our dependencies as interfaces in the same package, rather than importing an interface from another package. This approach is DIP.
Perhaps your inner skeptic is going crazy, yelling, but this would mean I would have to define interfaces everywhere! Yes, that might be true. It could even result in a small amount of duplication. You will find, however, that the interfaces you would have defined without dependency inversion would have been fatter and more unwieldy, a fact that would have cost you more to work with in the future.
After applying DIP, you are unlikely to have any circular dependency issues. In fact, you will almost certainly find that the number of imports in your code drops significantly and your dependency graph becomes rather flat. In fact, many packages will only be imported by the main package.
- Reporting with Visual Studio and Crystal Reports
- Machine Learning with R Cookbook(Second Edition)
- Java深入解析:透析Java本質的36個話題
- Java Web開發技術教程
- MySQL數據庫管理與開發實踐教程 (清華電腦學堂)
- ADI DSP應用技術集錦
- Building Minecraft Server Modifications
- 區塊鏈底層設計Java實戰
- C/C++程序員面試指南
- 創意UI:Photoshop玩轉APP設計
- Django Design Patterns and Best Practices
- Scala Functional Programming Patterns
- jQuery Mobile Web Development Essentials(Second Edition)
- SQL Server實例教程(2008版)
- 一步一步學Spring Boot:微服務項目實戰(第2版)