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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.135.225