Open
Conversation
discphy
commented
Mar 4, 2025
Comment on lines
+6
to
+13
| public class Items { | ||
|
|
||
| private final List<Item> list = new ArrayList<>(); | ||
|
|
||
| public boolean isEmpty() { | ||
| return list.isEmpty(); | ||
| } | ||
| } |
Owner
Author
There was a problem hiding this comment.
일급 컬렉션으로 의미 있는 도메인 객체로 만들어 불변성을 유지하게 끔 리팩토링하였습니다.
Comment on lines
+17
to
+19
| public boolean hasNotInfo() { | ||
| return name.isEmpty() || email.isEmpty() || phoneNumber.isEmpty(); | ||
| } |
Owner
Author
There was a problem hiding this comment.
단일 책임 원칙을 준수하기 위해 사용자 정보 검증하는 메서드를 Member 객체에 분리 시켜 작성하였습니다.
Comment on lines
+19
to
+36
| public boolean validate() { | ||
| if (items.isEmpty()) { | ||
| log.info("주문 항목이 없습니다."); | ||
| return false; | ||
| } | ||
|
|
||
| if (totalPrice <= 0) { | ||
| log.info("올바르지 않은 총 가격입니다."); | ||
| return false; | ||
| } | ||
|
|
||
| if (member.hasNotInfo()) { | ||
| log.info("사용자 정보가 없습니다."); | ||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
| } |
Owner
Author
There was a problem hiding this comment.
조건문안에 부정 연산자를 제거하여 메서드명으로만 유추할 수 있도록 리팩토링 하였습니다.
Owner
Author
There was a problem hiding this comment.
추가적으로, 도메인 레이어에서 로깅하는게 조금 신경쓰입니다.. 더 좋은 리팩토링 방안이 있을까요?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📅 미션 일자
✅ 미션 내용
🔗 미션 링크