-
Notifications
You must be signed in to change notification settings - Fork 5
[야구게임] 박진현 리뷰부탁드립니다 #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
blueconecell
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
부족한 시간에 간결하게 코드를 잘 짜신 것 같아요!
테스트 코드까지 있었으면 더 좋았을 것 같아요
| public class ResultDTO { | ||
| private final int strikes; | ||
| private final int balls; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Result 도메인과 이름말곤 똑같이 생겼는데 따로 만든 이유가 있으실까요?
refree에서 return값을 ResultDto로 하면 어땠을까요?
jiffyin7
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
스터디 때 뵙겠습니다.
| public int getStrikes() { | ||
| return strikes; | ||
| } | ||
|
|
||
| public int getBalls() { | ||
| return balls; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getter 메서드 대신 toString 메서드를 구현해서 outputView에서 출력하는 방법은 어떨까요?
| private int countMatchingNumbers(List<Integer> computerNumbers, String userNumber) { | ||
| int count = 0; | ||
| for (char digitChar : userNumber.toCharArray()) { | ||
| int currentDigit = Character.getNumericValue(digitChar); | ||
| if (computerNumbers.contains(currentDigit)) { | ||
| count++; | ||
| } | ||
| } | ||
| return count; | ||
| } | ||
|
|
||
| private int countSamePositionMatches(List<Integer> computerNumbers, String userNumber) { | ||
| int count = 0; | ||
| int index = 0; | ||
| for (int computerDigit : computerNumbers) { | ||
| int userDigit = Character.getNumericValue(userNumber.charAt(index)); | ||
| if (computerDigit == userDigit) { | ||
| count++; | ||
| } | ||
| index++; | ||
| } | ||
| return count; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저도 고민했지만 마땅한 방법을 찾을 수 없어 여쭤봅니다.
countMatchingNumbers 로직과 countSamePositionMatches에서 userNumber를 순회한다는 중복된 로직이 발생합니다.
이를 줄이기 위해 리팩토링하는 방법이 있을까요?
| import java.util.HashSet; | ||
| import java.util.Set; | ||
|
|
||
| public class InputNumberValidationImpl implements InputNumberValidation { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
따로 유효성 검증 객체를 분리한다면 도메인에 있는 검증 로직과 분리되는 상황이 발생하는데
이러면서 코드 중복이 발생할거 같아요. (Baseball에서도 validateRange를 검증하고, InputNumberValidation에서도 validateRange하는 상황)
No description provided.