Skip to content

Conversation

@mins1031
Copy link

@mins1031 mins1031 commented Dec 4, 2025

안녕하세요!

4단계 작업해서 PR 드려요
이번주는 감기에 걸려서 생각보다 시간 투자를 못했네요..
이번주 남은 기간동안 로또와 자동차경주 5단계 마무리 하고 다음주부터 수강신청 집중적으로 도전해보려고합니다~

- LottoNum의 명확한 사용제한을 위해 싱글톤 패턴으로 구현
- LottoNum 싱글톤 패턴으로 변경을 위해 로또번호 풀을 LottoNum 내부로 이관
- LottoMachine의 인스턴스 메서드 -> 클래스 메서드화
- 총 상금 계산로직 캡슐화를 위해 WinStandard로 일부 이관
- 네이밍 개선 및 고민사항 의식의 흐름 작성
- 수동 요구사항 도입을 위해 유저 입력정보 클래스 생성
- LottoMachine 에 수동/자동 로또 생성 메서드 추가
- 메세지 출력 부분 개선
- 자동갯수 잘못 노출되는 부분 개선
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.

요즘 감기 걸린 분들이 많던데 ㅠㅠㅠ
확실히 4단계에 크게 변경된 부분은 많지 않네요. 👍
그럼에도 불구하고 2중 콜렉션 사용이나 Lottos 대신 ManualLottos를 생성한 점은 아쉬움이 남아 피드백 남겨 봤어요.
로또를 생성하는 부분이 여러 객체로 흩어져 복잡도가 높아보이는데요.
로또 생성 부분을 좀 더 응집도를 가지도록 구현해볼 것을 추천합니다.

"이번주 남은 기간동안 로또와 자동차경주 5단계 마무리" -> 적극 공감해요.
2개 미션 마무리하고 다음 주에 다음 미션 도전해도 충분합니다.

import lottogame.model.price.LottoPurchasePrice;
import lottogame.model.winner.WinnerResult;

public class LottoStore {
Copy link
Contributor

Choose a reason for hiding this comment

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

이 객체의 책임 중 로또를 생성하는 책임을 다음과 같은 인터페이스를 추가한 후 분리해 보는 도전을 해보면 어떨까?
코드를 보면 로또를 생성하는 부분이 여러 객체에 분산되어 있는 느낌이 든다.
인터페이스를 추가하고 자동/수동에 대한 구현체를 만들어 로또 생성 부분을 합쳐보면 어떨까?

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

public interface LottosGenerator {
    Lottos generate();
}


private boolean isOutOfLottoRange(int num) {
return num < MIN_NUM || num > MAX_NUM;
public static LottoNum getInstance(int num) {
Copy link
Contributor

Choose a reason for hiding this comment

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

effective java 책을 보면 정적 팩터리 메서드 이름에 대한 컨벤션 제안을 하고 있다.
이 컨벤션을 찾아 리팩터링 해보면 어떨까?

import java.util.Set;

public class ManualLottos {
private final List<Set<Integer>> manualLottos;
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
private final List<Set<Integer>> manualLottos;
private final List<Lotto> manualLottos;

Lottos와 다른 점이 있나?
굳이 분리할 필요가 있을까?

}

public static Set<Integer> askBeforeWinNums() {
public static List<Set<Integer>> askManualLottos() {
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
public static List<Set<Integer>> askManualLottos() {
public static List<Lotto> askManualLottos() {

2중 콜렉션 사용 금지

- getInstance 네이밍 컨벤션에 맞게 수정
- ManualLottos 제거
- LottoMachine 자동/수동 생성 행위 추가.
- 자동, 수동 로또 생성방식을 인터페이스 기반으로 변경
- LottoStore에서 자동, 수동 따로 생성해서 조합하는 방식에서 조합한 결과를 응답하는 행위를 LottoMachine으로 이관
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 22 to 23
Lottos autoLottos = new AutoLottoGenerator(autoLottoCount).generateLottos();
Lottos manualLottos = new ManualLottosGenerator(manualLottoNums).generateLottos();
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  로또를 합쳐서 반환;
    }
}

- 자동, 수동 로또 생성 인터페이스 구현채로 생성하게 변경
- 질문사항 주석추가.
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.

마지막 피드백 반영하느라 수고했어요. 👍
TotallyLottosGenerator에 남긴 주석 봤는데요.
TotallyLottosGenerator가 상태 값을 가지기 때문에 매번 생성할 수 밖에 없는 것 같아요.
이 피드백의 목적은 인터페이스 기반 개발과 컴포지트 디자인 패턴을 한번 경험해 보는데 의미가 있습니다.
로또의 경우 지금 상태에서 요구사항 추가가 거의 없기 때문에 피부로 효과를 느끼기는 힘들 것 같고요.
현장에서는 지속적인 요구사항 변경을 대응할 때 인터페이스 기반으로 개발했을 때 다른 부분에 영향을 미치지 않으면서 기능 추가를 할 수 있기 때문에 적절한 때에 인터페이스도 활용해 보면 좋겠습니다.

지금까지 로또 미션 진행하느라 수고했어요.

import java.util.stream.Collectors;
import lottogame.model.price.LottoPurchasePrice;

public class LottoMachine {
Copy link
Contributor

Choose a reason for hiding this comment

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

로또 생성과 관련한 로직이 LottosGenerator로 이동했기 때문에 이 객체는 제거해도 되지 않을까?

@javajigi javajigi merged commit 89190a4 into next-step:mins1031 Dec 11, 2025
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