3 ms·
Ouch. Java's checked exception straightjacket would mean that every code that calls startByInterviewId() would either have to handle exceptions or declare "thro
by bjourne 14y ago
Ouch. Java's checked exception straightjacket would mean that every code that calls startByInterviewId() would either have to handle exceptions or declare "throws Interview.NotActive, Interview.NotPublic, Interview.DoesNotExist, Account.EmailExists". The longer up in the callchain, the longer the throws-list becomes until the programmer either gives up and writes "throws Exception" or is forced to handle the exceptions in a half-assed way. Likely by writing an empty catch-clause and hoping that code piece is never reached. It's especially unnerving for the user of the method if they are sure the input data is valid. For example, if interviewId comes directly from the database, then Interview.DoesNotExist can't happen so having to catch it shouldn't be needed.
- dcminter 14y agoI would expect those exceptions to implement a Throwable interface, perhaps ServiceException. If you don't care about the specifics of the error then you catch that and handle it. If you do care then you're going to need to handle the specific cases anyway. Personally I like checked exceptions at layer boundaries.