Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: