Hacker News new | past | comments | ask | show | jobs | submit login

To me the case described in the article is actually one of the rarer uses of interfaces: you're the only one using a handful of methods from a single class which has many more.

If you're using all/most methods of the class, you'd be better off if the interface was defined directly by the class.

If there are many different users of the same subset of methods, it's better if the class designer declares that interface.

If there are multiple classes implementing the same interface, it's almost crucial that the implementers agree on and define the interface.

So I would say, the statement should be 'in general, interfaces belong in the package that implements value of the interface type; but don't forget that sometimes they can be declared by the code that uses them'.




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

Search: