官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 武强县| 克什克腾旗| 武威市| 克拉玛依市| 永定县| 沙雅县| 寻乌县| 建水县| 阿拉尔市| 阿鲁科尔沁旗| 清远市| 越西县| 庆城县| 禄劝| 兴海县| 广西| 论坛| 巴彦淖尔市| 南靖县| 桃源县| 临清市| 兴山县| 博兴县| 伊金霍洛旗| 福州市| 黄浦区| 灵石县| 广宁县| 榆社县| 西盟| 渑池县| 沧州市| 扶绥县| 阳谷县| 综艺| 德庆县| 库尔勒市| 阳朔县| 青河县| 日照市| 桐梓县|