3 ms·
This is backwards of how I think about it, so I'm curious what you're thinking. If an implementation of an interface can throw an exception that its interface
by hyperpape 6y ago
This is backwards of how I think about it, so I'm curious what you're thinking.
If an implementation of an interface can throw an exception that its interface doesn't declare, that breaks the abstraction. How can you safely use the interface? You either have to catch Exception (which is effectively the same as wrapping every exception in some InterfaceException class), or give up on handling any Exceptions thrown by the interface.
- jrimbault 6y agoI don't think this is backward of your understanding ? That's just how I phrased it 18 hours ago. The thing I find bad about it is not that exceptions have to be declared in the interface, that's good, it's that every implementations will have to declare them also, even in the case that a particular implementation has no failure mode.
- hyperpape 6y agoThis sounds like a misconception. Implementations don't have to declare the exceptions: https://news.ycombinator.com/item?id=23410443 https://news.ycombinator.com/item?id=23410443.