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

[럿고] 로또 자동 생성 미션 제출합니다. #130

Merged
merged 49 commits into from
Feb 23, 2020

Conversation

ksy90101
Copy link

안녕하세요. 이번 미션 리뷰 잘 부탁드리겠습니다.
궁금한 사항은 따로 DM으로 물어보겠습니다!
감사합니다!

joseph415 and others added 30 commits February 18, 2020 15:00
Copy link

@young891221 young891221 left a comment

Choose a reason for hiding this comment

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

안녕하세요! 럿고
로또 하시느라 고생하셨습니다.
몇 가지 개선을 하면 훨신 깔끔해 질 것 같아 피드백 드렸습니다.
확인 부탁드립니다ㅎㅎ

src/main/java/lotto/controller/LottoController.java Outdated Show resolved Hide resolved
return new WinningBalls(winningBallsInput, bonusBall);
} catch (RuntimeException e) {
OutputView.printErrorMessage(e.getMessage());
return generateWinningBalls();

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.

Custom Exception만 처리하였습니다. 이걸 맞는 말씀이신지 모르겠네요! 확인부탁드릴께요!

Choose a reason for hiding this comment

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

일단 이렇게 처리하면 최소한 알 수 없는 에러에도 generateWinningBalls()를 수행하지는 않겠네요.

src/main/java/lotto/domain/LottoTickets.java Outdated Show resolved Hide resolved
@CsvSource(value = {"1,2,3,4,5,6 FIRST_RANK","1,2,3,4,5,7 SECOND_RANK"
,"1,2,3,4,5,10 THIRD_RANK","1,2,3,4,44,45 FOURTH_RANK"
,"1,2,3,43,44,45 FIFTH_RANK", "1,2,40,41,42,43 NO_RANK"}, delimiter = ' ')
void select_rank_test(String input,WinningRank winningRank) {

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.

CsvSource를 이용하여, 이름을 지정하고 전반적으로 정리를 하였습니다. 제 생각은 CsvSource를 이용하는 것이 훨씬 괜찮다고 생각하는데... 혹시 리뷰어 분의 생각이 저와 다르다면 알려주세요~

Choose a reason for hiding this comment

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

정돈이 되서 훨씬 보기 좋네요:)

public PurchaseAmount(String purchaseAmount) {
this.purchaseAmount = InputValidationUtil.returnNumberWithNumberCheck(purchaseAmount);
InputValidationUtil.isPositiveNumber(this.purchaseAmount);
underLottoUnit();

Choose a reason for hiding this comment

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

validLottoUnit() or checkLottoUnit() 와 같은 네이밍 방식은 어떠신가요?

Copy link
Author

@ksy90101 ksy90101 Feb 21, 2020

Choose a reason for hiding this comment

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

validateLottoUnit 으로 변경하였습니다.

, THIRD_RANK(1_500_000,5)
, FOURTH_RANK(50_000,4)
, FIFTH_RANK(5_000,3)
,NO_RANK(0,0);

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.

컨벤션을 찾아보고 사용했어야 하는데, 놓쳤습니다!ㅠㅠ 수정하였습니다!

import java.util.Arrays;

public enum WinningRank {
FIRST_RANK(2_000_000_000,6)

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

@young891221 young891221 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 27 to 28
.filter(result -> result.winningBallCount == correctNumber)
.filter(result -> result.existingBonusBall == isBonusNumber)

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.

수정하였습니다~

import java.util.stream.Collectors;

public class WinningBallsUtils {
private List<LottoBall> winningBalls;

Choose a reason for hiding this comment

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

요것도 Set으로 하는게 어떨까요?

Copy link
Author

Choose a reason for hiding this comment

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

이 부분은 따로 DM으로 질문하였습니다!

Copy link
Author

Choose a reason for hiding this comment

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

정렬때문에 Set을 사용하지 않았는데, 생각해보니, WinningBall은 정렬을 할 필요가 없네요... ㅎㅎ DM으로 보내주신 답변과 같이 변경하였습니다~

int[] winningBallInputs = {1, 2, 3, 4, 5, 6};
int bonus = 7;

List<LottoBall> lottoTicket = Arrays.stream(lottoTicketNumbers)

Choose a reason for hiding this comment

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

LottoBalls 라는 객체를 만들어 lottoTicket, winningBallValues를 생성해 보도록 하면 코드가 훨씬 간결해 질 것 같네요.

Copy link
Author

@ksy90101 ksy90101 Feb 22, 2020

Choose a reason for hiding this comment

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

미리 다음주 미션을 살짝 한 느낌이네요~ 입력값을 받아서 Set를 생성할 수 있게 객체 생성하였습니다! 이렇게 하니깐, WinningBallUtil도 사라지네요! Util보다 객체가 더 어울려 보여서 둘이 기능을 합쳤습니다!

Comment on lines 34 to 36
WinningBalls winningBalls = new WinningBalls(winningBallValues, LottoBallFactory.findByLottoBall(bonus));
int correctCount = winningBalls.hitLottoBalls(new LottoTicket(lottoTicket));
boolean correctBonusNumber = winningBalls.hitBonusBall(new LottoTicket(lottoTicket));

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.

원하시는것이 되었는지 모르겠습니다. 일단 SelectRank가 아닌, generateWinningRank 이걸로 변경하였습니다. 어차피 generateWinningRank안에서 SelectRank가 실행이 되어서 중복을 피할수 있었다고 생각합니다! 또한 generateWinningRank은 테스트가 되어있지 않더라고요! 그래서 둘이 같이 할 수 있는 방법으로 변경하였습니다~

Choose a reason for hiding this comment

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

제가 생각한 방향과 일치합니다 👍

@ksy90101
Copy link
Author

이번에 첫번째 두번쨰 피드백을 보면서 많이 배웠습니다. 아직, 전반적으로 컨벤션에 대한 개념이 부족하고 중복코드와 테스트 코드와 가독성을 신경을 많이 못쓴거 같습니다. 2주차에는 이번에 피드백들을 보고 배운 것들을 적용해보겠습니다! 혹시 다른 피드백 있으시다면 또 남겨주세요! 감사합니다~

Copy link

@young891221 young891221 left a comment

Choose a reason for hiding this comment

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

많이 배우셨다니 저도 좋네요 💯
공통적인 부분은 추상화 시켜 사용하는 방향으로 고민 & 설계 한다면 나날이 발전할 거라 생각합니다.
이번 단계 고생하셨어요. 머지할게요ㅎㅎ

@young891221 young891221 merged commit 63bf3e0 into woowacourse:ksy90101 Feb 23, 2020
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.

None yet

3 participants