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

[1단계 - 로또 구현] 벡터(백승주) 미션 제출합니다. #580

Open
wants to merge 23 commits into
base: byesol
Choose a base branch
from

Conversation

Byesol
Copy link

@Byesol Byesol commented Feb 13, 2025

리뷰 요청 및 질문 정리

1. MVC 구조 및 Service 역할

이번 미션에서 MVC 구조를 사용하여 구현했는데, 올바르게 작성된 구조인지 궁금합니다. 또한, 다른 크루들의 코드를 보니 서비스를 추가해서 구현하는 경우를 봤습니다.

  • Model을 단순한 데이터 객체로 두고, Service를 통해 비즈니스 로직을 처리하는 것이 더 객체지향적인 접근 방식인가요?
  • 현재 View 코드 내부에서 유효성 검사(Validation)를 진행하고 있는데, 이를 별도의 Validator 클래스로 분리하는 것이 좋을까요?

2. Enum을 활용한 당첨 결과 타입 정리와 그 개수 관리

현재 로또 당첨 결과를 Enum 타입으로 정의하고, 참가자의 1등, 2등 등의 당첨 결과에 대한 것들을 enummap으로 result란 클래스에서 해당 당첨지의 개수를 저장했는데 이렇게 result란 클래스를 만들어 저장하는것보다 아예 고객에 대한 구입 금액, 결과 등을 저장하는 방식이 더 괜찮을까요?

https://prolog.techcourse.co.kr/studylogs/3872

@Byesol Byesol changed the title [1단계 - 로또 구현] 벡터(백승) 미션 제출합니다. [1단계 - 로또 구현] 벡터(백승주) 미션 제출합니다. Feb 13, 2025
Copy link

@dusdn1702 dusdn1702 left a comment

Choose a reason for hiding this comment

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

안녕하세요 벡터!
첫 리뷰를 맡게 된 샐리라고 합니다 🙇🏻‍♀️

시간이 많지 않으셨을텐데 첫 미션에 테스트까지 정말 잘 구현해주셨네요 👍
고생 많으셨습니다 👏
간단한 코멘트 몇개 남겨 두었어요 확인 부탁드릴게요 !


### 로또 구매

- [x] 구입금액 안내멘트를 출력한다.

Choose a reason for hiding this comment

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

todo 처리 좋네요 👍

@@ -0,0 +1,10 @@
package constant;

public class ErrorMessage {

Choose a reason for hiding this comment

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

에러 메시지 분리까지! 👏

Comment on lines +16 to +18
private final Integer matchNumberCount;
private final Boolean matchBonusNumber;
private final Integer price;

Choose a reason for hiding this comment

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

reference type을 사용하신 이유가 있으실까요?

public static WinLottoInfo result(LottoNumbers purchasedLotto, WinLotto winLotto) {
Integer matchNumberCount = winLotto.countMatchNumber(purchasedLotto);
Boolean bonusMatch = winLotto.bonusMatch(purchasedLotto);
if (matchNumberCount <= 2) {

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 LottoNumbers() {
this.numbers = generateLottoNumbers();
}

public LottoNumbers(List<Integer> numbers) {
this.numbers = numbers;
}

Choose a reason for hiding this comment

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

이렇게 생성자를 나눠서 만들어주신 이유가 궁금하네요 👀

}

public Integer readPurchaseAmount() {
Scanner sc = new Scanner(System.in);

Choose a reason for hiding this comment

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

의미있는 변수명을 사용해보면 어떨까요?

for (Entry<WinLottoInfo, Integer> winLottoInfoIntegerEntry : result.entrySet()) {
WinLottoInfo winLottoInfo = winLottoInfoIntegerEntry.getKey();
Integer count = winLottoInfoIntegerEntry.getValue();
sum += winLottoInfo.getPrice() * count;

Choose a reason for hiding this comment

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

이렇게 사칙연산으로 구현하게 되면 계산의 우선순위에 대해 검증이 어렵지 않을까요?

nullToZero(result.getCount(FIRST)));
}

public void printTotalReturn(Result result, Purchase purchase) {

Choose a reason for hiding this comment

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

우리가 코드에서 많이 사용하는 return이란 단어가 함수명에 들어가있으니 어색하게 느껴지는데 벡터는 어떠신가요?

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

class WinLottoInfoTest {

Choose a reason for hiding this comment

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

테스트 작성까지 !! 💯

@dusdn1702
Copy link

남겨주신 질문도 답변드립니다 ~ 같이 고민해봐요 !

  1. MVC 구조 및 Service 역할
    잘 작성해주신 것 같아요!
    model을 데이터 객체로 분리하면 어떤 장점이 있다고 생각하시나요? 서비스에서 비즈니스 로직을 처리하는 것과 작성해주신 것처럼 도메인이 비즈니스 로직을 처리하는 것 각각의 장단점에 대해 생각해보면 좋을 것 같아요 😄
    입출력에 대한 유효성은 비즈니스 로직이 아니니 view에서 처리해주셨을 것 같은데요! 유효성만 담당하는 validator 클래스 분리도 좋을 것 같아요. 다만, 유효성이 입출력에 대한 것 뿐만 아니라 비즈니스적인 유효성이 추가된다면 어떻게 관리하는 것이 좋을까요?

  2. Enum을 활용한 당첨 결과 타입 정리와 그 개수 관리
    작성해주신 것처럼 구현하게되면 결국에 어디선가 enum 매핑이 되어야하고 지금은 그걸 WinLottoInfo라는 객체에서 처리하고 있는데요! 어떤 것에 중점을 두느냐에 차이일 것 같아요. 추후 확장성과 유지보수성을 생각하면 지금 구조는 enum이 추가되고 로직이 복잡해질수록 매핑하는 데에 어려움이 있지 않을까요?

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