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

> I specifically mention that it's not a great idea. It's a code smell. Instead, interfaces should be defined at point-of-use.

You still have not said WHY it's not a great idea, or what the benefits of defining the interfaces at point-of-use are.



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: