Skip to content

Conversation

@username0w
Copy link

안녕하세요.
4단계 - 로또(수동) PR 입니다.

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.

앞 단계의 객체 설계를 잘 구현해 놓다보니 최종 결과 값과 수익률 계산 등의 객체에 영향을 주지 않으면서 구현 잘 했네요. 👍
단, 로또를 생성하는 부분에 변화가 많았는데요.
로또 생성하는 부분도 요구사항 변화에 유연하게 대응하기 위해 도전해 봤으면 하는 부분이 있어 피드백 남겼어요.

private static final String ERROR_OUT_OF_RANGE = "로또 번호는 1~45 범위의 숫자여야 한다";

private static final LottoNumber[] CACHE = new LottoNumber[MAX_NUMBER + 1];
private static final Map<Integer, LottoNumber> CACHE = new HashMap<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

import lotto.view.InputView;
import lotto.view.ResultView;

public class LottoApplication {
Copy link
Contributor

Choose a reason for hiding this comment

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

전체 로또 프로그램에 대한 Controller 역할(main)과 로또를 생성하는 책임이 혼재되어 있는 느낌이다.
로또 생성하는 부분을 다음과 같은 구조로 구현해 분리해 보면 어떨까?


3단계에서 4단계로 요구사항이 변경될 때 로또를 생성하는 부분의 요구사항만 변경됐다.
로또를 생성하는 부분을 다음과 같은 구조의 인터페이스로 분리해 보는 연습을 해보면 어떨까?
이와 같이 인터페이스로 구현했을 때의 잇점에 대해 고민해 보는 시간을 가져본다.

public interface LottosGenerator {
    Lottos generate();
}

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.

피드백 반영 잘 했네요. 👍
딱히 다른 부분에 대한 피드백은 없고, 디자인 패턴 중 컴포지트 패턴을 경험해 봤으면 하는 바람으로 피드백 남겨봤어요.
로또 미션의 마지막 피드백이 될 것 같네요.

Comment on lines 13 to 15
ManualLottoCount manualCount = createManualLottoCount(amount);
Lottos manualLottos = createManualLottos(manualCount);
Lottos autoLottos = LottoMachine.randomLottos(amount.autoCount(manualCount));
Lottos autoLottos = new AutoLottosGenerator(amount.autoCount(manualCount)).generate();
Copy link
Contributor

Choose a reason for hiding this comment

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

이와 같이 인터페이스를 구현하고, 구현체가 서로 연결되어 있는 경우 아래와 같은 구현체를 통해 구현체를 통합할 수 있음.
보통 디자인 패턴에서 컴포지트 패턴으로 알려져 있음.
아래와 같은 객체 추가에 따른 효과를 느껴 봤으면 하는 바람으로 피드백 남겨봄.

public class LottosBundleGenerator implements LottosGenerator {
    private final Money money;
    private final List<String> manualLottoText;

    public LottosBundleGenerator(Money money, List<String> manualLottoText) {
        this.money = money;
        this.manualLottoText = manualLottoText;
    }

    @Override
    public Lottos generate() {
        // ManualLottosGenerator 활용해 수동 로또 생성
        // AutoLottosGenerator 활용해 자동 로또 생성(수동 로또 수 만큼 Money 차감)
        return  로또를 합쳐서 반환;
    }
}

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