Source:
<code>private void verifyIsUserOfCourse(String courseId, String commentGiver, FeedbackParticipantType commentGiverType, boolean isCommentFromFeedbackParticipant) throws EntityDoesNotExistException { if (isCommentFromFeedbackParticipant) { switch (commentGiverType) { case STUDENTS: StudentAttributes student = studentsLogic.getStudentForEmail(courseId, commentGiver); if (student == null) { throw new EntityDoesNotExistException("User " + commentGiver + " is not a registered student for course " + courseId + "."); } break; case INSTRUCTORS: InstructorAttributes instructor = instructorsLogic.getInstructorForEmail(courseId, commentGiver); if (instructor == null) { throw new EntityDoesNotExistException("User " + commentGiver + " is not a registered instructor for course " + courseId + "."); } break; case TEAMS: List<TeamDetailsBundle> teams = coursesLogic.getTeamsForCourse(courseId); boolean isTeamPresentInCourse = false; for (TeamDetailsBundle team : teams) { if (team.name.equals(commentGiver)) { isTeamPresentInCourse = true; break; } } if (!isTeamPresentInCourse) { throw new EntityDoesNotExistException("User " + commentGiver + " is not a registered team for course " + courseId + "."); } break; default: throw new EntityDoesNotExistException("Unknown giver type: " + commentGiverType); } } else { InstructorAttributes instructor = instructorsLogic.getInstructorForEmail(courseId, commentGiver); if (instructor == null) { throw new EntityDoesNotExistException("User " + commentGiver + " is not a registered instructor for course " + courseId + "."); } <START> } <END> }</code><technical_language>Consider dealing shorter branch first. improves readability</technical_language>

Target:
private void verifyIsUserOfCourse(String courseId, String commentGiver, FeedbackParticipantType commentGiverType, boolean isCommentFromFeedbackParticipant) throws EntityDoesNotExistException { if (!isCommentFromFeedbackParticipant) { InstructorAttributes instructor = instructorsLogic.getInstructorForEmail(courseId, commentGiver); if (instructor == null) { throw new EntityDoesNotExistException("User " + commentGiver + " is not a registered instructor for course " + courseId + "."); } return; } switch (commentGiverType) { case STUDENTS: StudentAttributes student = studentsLogic.getStudentForEmail(courseId, commentGiver); if (student == null) { throw new EntityDoesNotExistException("User " + commentGiver + " is not a registered student for course " + courseId + "."); } break; case INSTRUCTORS: InstructorAttributes instructor = instructorsLogic.getInstructorForEmail(courseId, commentGiver); if (instructor == null) { throw new EntityDoesNotExistException("User " + commentGiver + " is not a registered instructor for course " + courseId + "."); } break; case TEAMS: List<TeamDetailsBundle> teams = coursesLogic.getTeamsForCourse(courseId); boolean isTeamPresentInCourse = false; for (TeamDetailsBundle team : teams) { if (team.name.equals(commentGiver)) { isTeamPresentInCourse = true; break; } } if (!isTeamPresentInCourse) { throw new EntityDoesNotExistException("User " + commentGiver + " is not a registered team for course " + courseId + "."); } break; default: throw new EntityDoesNotExistException("Unknown giver type: " + commentGiverType); } }