Skip to content

Conversation

@tiemo0708
Copy link

No description provided.

Copy link

@blueconecell blueconecell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

부족한 시간에 간결하게 코드를 잘 짜신 것 같아요!
테스트 코드까지 있었으면 더 좋았을 것 같아요

Comment on lines +3 to +6
public class ResultDTO {
private final int strikes;
private final int balls;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Result 도메인과 이름말곤 똑같이 생겼는데 따로 만든 이유가 있으실까요?
refree에서 return값을 ResultDto로 하면 어땠을까요?

Copy link

@jiffyin7 jiffyin7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

스터디 때 뵙겠습니다.

Comment on lines +12 to +18
public int getStrikes() {
return strikes;
}

public int getBalls() {
return balls;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
}

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 {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

따로 유효성 검증 객체를 분리한다면 도메인에 있는 검증 로직과 분리되는 상황이 발생하는데
이러면서 코드 중복이 발생할거 같아요. (Baseball에서도 validateRange를 검증하고, InputNumberValidation에서도 validateRange하는 상황)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants