3 ms·
Fixed your original code for you: public Session startByInterviewId(Long interviewId, String email, String name) { Interview interview = interviewS
by bruceboughton 14y ago
Fixed your original code for you:
public Session startByInterviewId(Long interviewId, String email, String name) {
Interview interview = interviewService.getPublicById(interviewId);
if (interview == null) {
return null;
}
Account user = userService.createUser(name, email, interview.getLocale());
if (user == null) {
return null;
}
return startByInterview(interview, user);
}
Besides that, you have not magically reduced LOCs, you have moved them elsewhere so these code blocks are not equivalent.
- mtrimpe 14y agoWe could always say that you shouldn't use return statements for control flow to complicate things further. ;) Your code doesn't preserve information about what caused the failure though. And also, I actually did magically reduce lines of code since I can just let the exceptions I fix bubble up and I've customized my web framework to turn them into appropriate error pages and the the <Class>.NotFound exceptions are even annotated so that they're automatically turned into 404s.