News for hackers. Stuff that matters.
Re:How to Use Go Interfaces by chewxy on Tuesday March 20, 2018 @07:40PM (#16633866)
The benefits of defining interfaces at point of use is decoupling of dependencies.

Imagine you have two packages: A and B. A defines interface Fooer and struct FooThing. Package B only requires anything that can call Foo(). But because the interface is defined at A, now B is forever tied to A. When you change something in A, you have to worry if it changes something in B as well.

If instead the interface Fooer is defined in B, package A can change as much as it likes without B needing to change.

There are no comments on this comment yet.