✅ 작업 범위
NotificationSender<T> 인터페이스 리팩토링
EmailNotificationSender 구현체 예외 처리 흐름 정비
🔹 NotificationSender 인터페이스
public interface NotificationSender<T extends Message> {
SendResult send(T message) throws NotificationSendException;
}
✅ 리뷰 요약
T extends Message → 타입 안정성 확보
throws NotificationSendException → 예외 흐름 명시됨
- JavaDoc 명세가 깔끔하게 작성됨 → 실무 수준 계약 명세
🔹 EmailNotificationSender 구현체
public SendResult send(EmailMessage message) throws NotificationSendException {
try {
Transport.send(null);
} catch (MessagingException e) {
Exception nextEx = e.getNextException();
String errorCode = "SEND_ERROR";
String errorMsg = nextEx.getMessage();
throw new NotificationSendException("MAIL", errorCode, errorMsg);
}
return new SendResult(true, "success", null);
}
✅ 장점
- 구체적인 예외 분기 및 메시지 해석 → 실무 예외 관리 흐름에 적합
- 실패 시 예외 throw, 성공 시
SendResult 반환 → 명확한 분기
⚠ 개선 포인트
SendResult SendResult = ... → 변수명 camelCase로 수정 필요 (sendResult)
- 성공
SendResult는 try 블록 성공 이후에 생성하는 편이 안전
Transport.send(null)은 명시적 TODO 코멘트 권장
🧠 티쳐 총평
- 전반적으로 실무 수준의 예외 흐름과 구조를 갖춘 리팩토링
- 세부 스타일과 흐름에서 한층 더 깔끔한 책임 분리를 정비할 수 있음
- 다음 단계로
Notification 호출 구조 및 Factory 반환 안전성 연결 추천