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

[로또 미션] 최규원 미션 제출합니다. #8

Open
wants to merge 5 commits into
base: kyuwon-choi
Choose a base branch
from

Conversation

Kyuwon-Choi
Copy link

안녕하세요 리뷰어님.

저는 우선 저번 리뷰 때 MVC 패턴에 대한 이해가 완벽하지 않은 것 같다고 느껴 이번 과제에선 MVC 패턴을 조금 더 신경쓰면서 진행해 보았습니다.

기능 구현을 먼저 하고 그 이후에 원시값과 문자열을 포장하여 조금 난잡할 수도 있겠지만 양해 부탁드립니다!

신경쓴 부분들

  • mvc
  • 원시값 포장, 일급 컬렉션
  • constant 클래스를 따로 나눠 상수 관리
  • public과 private

궁금한 부분
-controller에선 int price같은 변수선언을 아예 하지 않는게 좋은지

갑사합니다!

Copy link

@day024 day024 left a comment

Choose a reason for hiding this comment

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

안녕하세요 규원님! 코드리뷰를 맡게된 정다영이라고합니다.

제가 아직 자바에 익숙치 않아서 세세하게 리뷰를 진행하지 못한 점 양해 부탁드립니다!
코드가 명확하게 짜여있고 변수명도 직관적이라 리뷰 진행이 수월했던 것 같습니다.
mvc을 신경쓰셨다고 했는데 코드에도 잘 적용되어 있는게 느껴졌습니다. 코드에서 많은 노력을 하신게 느껴집니다.

규원님 코드를 보면서 제가 더 많이 배워갔던 것 같습니다!

Copy link

Choose a reason for hiding this comment

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

controller에선 int price같은 변수 선언을 아예 하지 않는 게 좋은 지에 대해서 질문 주셨는데요.
저도 이 부분을 고민하였지만, 기능 구현에 한계가 있어 결국 작성할 때는 변수 선언을 진행 하였습니다ㅠㅠ.
저의 생각으론 최대한 지양하는 것이 좋을 것 같다고 생각합니다! 컨트롤러는 최대한 가볍게 작성하는 것이 좋다고 생각하기 때문이에요.
아래 MVC 패턴에 관한 글인데 한번 보시면 좋을 것 같아요. 규원님도 이부분을 어떻게 생각하지는지도 궁금합니다!

https://newwisdom.tistory.com/58

Copy link
Author

Choose a reason for hiding this comment

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

넵 반영해서 수정해보겠습니다!

Copy link

Choose a reason for hiding this comment

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

constant class를 통해 상수를 정리하셨는데 이 덕분에 코드가 깔끔해진 것 같아요 👍

Comment on lines +6 to +20
public LottoMoney(String inputAmount) {
try {
int amount = Integer.parseInt(inputAmount);
validateAmount(amount);
this.amount = amount;
} catch (NumberFormatException e) {
throw new IllegalArgumentException(Constant.PRICE_VALUE_EXCEPTION, e);
}
}

private void validateAmount(int amount) {
if (amount % Constant.LOTTO_PRICE != 0 || amount < Constant.LOTTO_PRICE) {
throw new IllegalArgumentException(Constant.LOTTO_PRICE_EXCEPTION);
}
}
Copy link

Choose a reason for hiding this comment

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

각각의 예외처리가 잘들어간 것 같아요!

Comment on lines 39 to 57
public List<Lotto> generateLotto() {
List<Lotto> lottos = convertManualLottoList(manualLottoList);

for (int i = 0; i < lottoCount; i++) {
lottos.add(new Lotto(generateRandomNumbers()));
}

return lottos;
}

private List<LottoNumber> generateRandomNumbers() {
Collections.shuffle(numberList);
return numberList.subList(Constant.ZERO_COUNT, Constant.LOTTO_SIZE)
.stream()
.map(n -> new LottoNumber(String.valueOf(n)))
.sorted(Comparator.comparingInt(LottoNumber::getNumber)) // 정렬
.collect(Collectors.toList());
}
}
Copy link

Choose a reason for hiding this comment

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

BuyLotto에서 로또 구매와 생성이 모두 이루어지고 있는데요 두가지를 분리해보는것은 어떨까요?

Copy link
Author

Choose a reason for hiding this comment

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

반영하여 수정하였습니다!

Comment on lines +41 to +62
public void updateWinningStates(List<Lotto> userLottos) {
userLottos.forEach(userLotto -> {
int matchedNumbers = compareHowManyNumberSame(userLotto);
boolean containsBonus = userLotto.getNumbers().stream().anyMatch(number -> number.getNumber() == bonusBall.getNumber());

if (matchedNumbers == Constant.SIX_COUNT) {
updateWinningState(LottoPrize.FIRST);
}
if (matchedNumbers == Constant.FIVE_COUNT && containsBonus) {
updateWinningState(LottoPrize.SECOND);
}
if (matchedNumbers == Constant.FIVE_COUNT && !containsBonus) {
updateWinningState(LottoPrize.THIRD);
}
if (matchedNumbers == Constant.FOUR_COUNT) {
updateWinningState(LottoPrize.FOURTH);
}
if (matchedNumbers == Constant.THREE_COUNT) {
updateWinningState(LottoPrize.FIFTH);
}
});
}
Copy link

Choose a reason for hiding this comment

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

내부에 코드가 길어지는 것 같은데 더 간단하게 매소드를 쪼개보면 어떨까요?

Copy link
Author

Choose a reason for hiding this comment

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

쪼갤려고 시도를 해봤는데 들여쓰기 조건이 생각보다 까다로워서 일단 이렇게 뒀습니다ㅠ
한번 더 생각해보겠습니다!

Copy link

Choose a reason for hiding this comment

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

Constant에 상수를 잘 정리해두셔서 ResultView가 한층더 보기 명확해진 것 같습니다👍👍

Copy link

Choose a reason for hiding this comment

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

테스트도 잘 진행한 것 같아보여요!

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