Skip to content
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

Step2 #3254

Open
wants to merge 2 commits into
base: dnjswhdzld
Choose a base branch
from
Open

Step2 #3254

wants to merge 2 commits into from

Conversation

dnjswhdzld
Copy link

많이 늦었네요... 잘 부탁드립니다

Copy link
Contributor

@javajigi javajigi left a comment

Choose a reason for hiding this comment

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

2단계 구현하느라 수고했어요. 👍
로직 구현할 때 상태를 가지는 객체에 로직을 구현하기 보다(즉, 객채에 메시지를 보낸다.) 객체 외부로 값을 꺼내 로직을 구현하는 부분이 보이네요.
객체에 메시지를 보내고, 테스트 코드를 구현해 보면 좋겠어요.

리뷰어가 업무가 너무 바빠 제가 대신 피드백 남겼어요.

Comment on lines +16 to +17
ResultView resultView = new ResultView();
InputView inputView = new InputView();
Copy link
Contributor

Choose a reason for hiding this comment

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

상태 값을 가지지 않는데 굳이 인스턴스를 생성할 필요가 있을까?
클래스 메서드(static)로 구현해도 되지 않을까?

Comment on lines +26 to +28
List<Rank> ranks = lottos.stream()
.map(lotto -> lotto.getRank(winningLotto.getWinningLottoNums()))
.collect(Collectors.toList());
Copy link
Contributor

Choose a reason for hiding this comment

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

Lottos와 같은 일급 콜렉션을 만들고 이 객체에 이 로직을 위임하는 것은 어떨까?
List<Rank> ranks = lottos.match(winningLotto);

또는 아래에 있는 Winnings winnings = lottos.match(winningLotto);를 반환하고, Winnings가 List를 상태 값으로 가지는 것도 좋지 않을까?

@@ -0,0 +1,28 @@
package step2.domain;

public class Amount {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍


private final int amount;

public Amount(int amount) {
Copy link
Contributor

Choose a reason for hiding this comment

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

amount 값에 대한 유효성 체크를 이 생성자에서 진행하는 것은 어떨까?

Comment on lines +4 to +6
public static final int MIN_NUM = 1;
public static final int MAX_NUM = 45;
public static final int LOTTO_NUM_SIZE = 6;
Copy link
Contributor

Choose a reason for hiding this comment

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

이 상수들은 Lotto 또는 LottoNums와 같이 관련 있는 곳에 위치하는 것은 어떨까?


public LottoNum(int num) {
this.num = num;
validateLottoNum();
Copy link
Contributor

Choose a reason for hiding this comment

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

유효성 체크를 먼저하는 것은 어떨까?

Comment on lines +37 to +43
LottoNums lottoNums = new LottoNums(new LottoNums.Builder()
.lottoNum(new LottoNum(1))
.lottoNum(new LottoNum(2))
.lottoNum(new LottoNum(16))
.lottoNum(new LottoNum(19))
.lottoNum(new LottoNum(30))
.lottoNum(new LottoNum(32)));
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
LottoNums lottoNums = new LottoNums(new LottoNums.Builder()
.lottoNum(new LottoNum(1))
.lottoNum(new LottoNum(2))
.lottoNum(new LottoNum(16))
.lottoNum(new LottoNum(19))
.lottoNum(new LottoNum(30))
.lottoNum(new LottoNum(32)));
LottoNums lottoNums = new LottoNums(1, 2, 16, 19, 30, 32);

위와 같이 생성할 수 있는 생성자를 추가하는 것은 어떨까?

Comment on lines +45 to +51
List<LottoNum> lottoNumList = new ArrayList<>();
lottoNumList.add(new LottoNum(1));
lottoNumList.add(new LottoNum(2));
lottoNumList.add(new LottoNum(16));
lottoNumList.add(new LottoNum(19));
lottoNumList.add(new LottoNum(30));
lottoNumList.add(new LottoNum(32));
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
List<LottoNum> lottoNumList = new ArrayList<>();
lottoNumList.add(new LottoNum(1));
lottoNumList.add(new LottoNum(2));
lottoNumList.add(new LottoNum(16));
lottoNumList.add(new LottoNum(19));
lottoNumList.add(new LottoNum(30));
lottoNumList.add(new LottoNum(32));
List<LottoNum> lottoNumList = Arrays.asList(
new LottoNum(1), new LottoNum(2), new LottoNum(16), new LottoNum(19), new LottoNum(30), new LottoNum(32);

테스트 코드에 List를 생성할 때 Arrays 사용하면 유용한 경우 많다.

WinningLotto winningLotto = new WinningLotto(lottoNums);
assertThat(lotto.getRank(winningLotto.getWinningLottoNums())).isEqualTo(new Rank(6));
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Rank를 구하는 테스트 코드도 추가해 보는 것은 어떨까?

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.

2 participants