Open
Conversation
blueconecell
left a comment
There was a problem hiding this comment.
부족한 시간에 간결하게 코드를 잘 짜신 것 같아요!
테스트 코드까지 있었으면 더 좋았을 것 같아요
Comment on lines
+3
to
+6
| public class ResultDTO { | ||
| private final int strikes; | ||
| private final int balls; | ||
|
|
There was a problem hiding this comment.
Result 도메인과 이름말곤 똑같이 생겼는데 따로 만든 이유가 있으실까요?
refree에서 return값을 ResultDto로 하면 어땠을까요?
jiffyin7
reviewed
Nov 20, 2024
Comment on lines
+12
to
+18
| public int getStrikes() { | ||
| return strikes; | ||
| } | ||
|
|
||
| public int getBalls() { | ||
| return balls; | ||
| } |
There was a problem hiding this comment.
getter 메서드 대신 toString 메서드를 구현해서 outputView에서 출력하는 방법은 어떨까요?
Comment on lines
+23
to
+45
| 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.
저도 고민했지만 마땅한 방법을 찾을 수 없어 여쭤봅니다.
countMatchingNumbers 로직과 countSamePositionMatches에서 userNumber를 순회한다는 중복된 로직이 발생합니다.
이를 줄이기 위해 리팩토링하는 방법이 있을까요?
| import java.util.HashSet; | ||
| import java.util.Set; | ||
|
|
||
| public class InputNumberValidationImpl implements InputNumberValidation { |
There was a problem hiding this comment.
따로 유효성 검증 객체를 분리한다면 도메인에 있는 검증 로직과 분리되는 상황이 발생하는데
이러면서 코드 중복이 발생할거 같아요. (Baseball에서도 validateRange를 검증하고, InputNumberValidation에서도 validateRange하는 상황)
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.
No description provided.