Skip to content

[🚀 사이클2 - 미션 (블랙잭 게임 실행)] 루덴스 미션 제출합니다.#1138

Open
poketopa wants to merge 33 commits intowoowacourse:poketopafrom
poketopa:step2
Open

[🚀 사이클2 - 미션 (블랙잭 게임 실행)] 루덴스 미션 제출합니다.#1138
poketopa wants to merge 33 commits intowoowacourse:poketopafrom
poketopa:step2

Conversation

@poketopa
Copy link

체크 리스트

  • 미션의 필수 요구사항을 모두 구현했나요?
  • Gradle test를 실행했을 때, 모든 테스트가 정상적으로 통과했나요?
  • 애플리케이션이 정상적으로 실행되나요?

어떤 부분에 집중하여 리뷰해야 할까요?

찰리 이번에도 잘 부탁드립니다!

사이클 1에서 해주셨던 리뷰들을 통해서 많은 생각을 했고, 그 과정에서 성장도 있었다고 생각합니다!

이번 사이클 2에서는 사이클 1에서 느꼈던 코드를 작성할 때는 이런 식으로 생각해야 하는구나를 최대한 의식하면서 필요한 기능을 어떤 객체가 책임지게 할 것인지에 대해 고민하면서 작성했습니다.

사이클 1의 마지막 리뷰에 남겨주신 코멘트들에 대한 적용 사항과 추가된 기능 관련은 코멘트에 남기겠습니다!

poketopa added 30 commits March 17, 2026 12:29
Comment on lines 14 to -15
private final List<Card> cards;
private int score;
Copy link
Author

Choose a reason for hiding this comment

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

score이 필드로 존재할 필요가 있냐는 코멘트를 보고 score 필드를 삭제하고 계산할 때만 합산해서 사용하는 방식으로 수정했습니다.

scoreaceCount(이전에 삭제된 필드)는 Cards를 통해서 알 수 있는 정보이기 때문에 굳이 필드로 만들어 관리할 필요가 없고, 더군다나 Score이 상태로서 존재한다면 Cards가 변할 때 score를 계속 동기화 해줘야 하는 리스크가 존재할 뿐이라고 생각했습니다!

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.

기존에는 view가 Players와 Dealer 객체를 직접 받아 출력하고 있었습니다.

기능이 계속 추가되는 상황에서 DTO를 만들어 놓는 것이 부담이라고 생각해서 위와 같은 방식을 사용했었지만, (사실 귀찮아서 생각해낸 핑계 같습니다)

view에서 도메인을 제어할 수 있다는 것은 큰 리스크가 될 수 있다고 생각하여 DTO를 도입했습니다.

현재 view는 원시값만을 받아 출력합니다.

컨트롤러가 DTO 매핑까지 담당하게 되면 컨트롤러가 너무 비대해지고, 기능 추가 시 컨트롤러에 코드를 직접 추가해야 하기 때문에 Mapper 객체 따로 만들어 관리하는 것이 좋다고 생각하여 분리했습니다!

Copy link

Choose a reason for hiding this comment

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

DTO를 만들어주신점 좋네요! 👍👍👍


한 곳에서 모든 변환을 담당하면 한 눈에 확인할 수 있다는점은 장점이자 단점이 될 수 있다고 생각해요
현재도 꽤 변환메서드가 존재하는데 기능이 추가될 수 록 더 많아지겠죠~!

코드 에디터의 기능을 사용하면 쉽게 원하는 코드를 찾을 수도 있지만
단순히 클래스만 본다면 어디에 내가 원하는 변환 메서드가 있는지 찾을 수 있을까요?

각 dto 클래스 생성자나 정정 팩토리 메서드에서 필요한 값을 받아서 변환하는것은 어떻게 생각하시나요?
반영했을 때 어떤 장점이 있는지 현재 구현의 장점과 비교해보시죠!


public final class Player extends Participant {
private final Name name;
private Betting betting;
Copy link
Author

@poketopa poketopa Mar 18, 2026

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.

넵 플레이어와 관계가 깊은 정보이니 가지는게 합리적이라 생각해요!


public abstract class Participant {
private final Hand hand;
private Balance balance;
Copy link
Author

Choose a reason for hiding this comment

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

참가자는 Balance (최종 수익)을 가지도록 했습니다. score처럼 한판이 끝난 뒤 연산할 수도 있지만, 최종 수익이라는 것은 게임이 여러 판 진행되었을 때 누적될 수 있다고 생각하여 상태로서 가질 수 있게 필드로 추가했습니다!

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 -4 to +7
WIN("승"), LOSE("패"), DRAW("무");
BLACKJACK_WIN("승", 1.5),
DEFAULT_WIN("승", 1.0),
DRAW("무", 0.0),
LOSE("패", -1.0);
Copy link
Author

Choose a reason for hiding this comment

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

승리 시에 블랙잭으로 승리 (배팅금 1.5배 적용)와 일반 승리 (배팅금 1배 적용)로 결과가 나뉘기 때문에 기존 , , 로 관리하던 ENUM 결과를

  • BLACKJACK_WIN
  • DEFAULT_WIN
  • DRAW
  • LOSE
    4개로 분리했습니다.

HandState에서 조건 분기를 통해 OutCome을 얻습니다.

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.

결국 사용처는 InputView 밖에 없는데 별도 클래스에 두신것에는 어떤 배경이 있었나요?
루덴스가 생각한 장점을 공유해주세요~
그리고 단점도 고민해보셨을까요?

Copy link

@Gomding Gomding left a comment

Choose a reason for hiding this comment

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

안녕하세요 루덴스!
사이클2 잘 진행해주셨네요~
코멘트 남겼으니 확인부탁드려요 :)

궁금한 점 있으면 언제든 DM 이나 코멘트 남겨주세요 😄

Copy link

Choose a reason for hiding this comment

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

DTO를 만들어주신점 좋네요! 👍👍👍


한 곳에서 모든 변환을 담당하면 한 눈에 확인할 수 있다는점은 장점이자 단점이 될 수 있다고 생각해요
현재도 꽤 변환메서드가 존재하는데 기능이 추가될 수 록 더 많아지겠죠~!

코드 에디터의 기능을 사용하면 쉽게 원하는 코드를 찾을 수도 있지만
단순히 클래스만 본다면 어디에 내가 원하는 변환 메서드가 있는지 찾을 수 있을까요?

각 dto 클래스 생성자나 정정 팩토리 메서드에서 필요한 값을 받아서 변환하는것은 어떻게 생각하시나요?
반영했을 때 어떤 장점이 있는지 현재 구현의 장점과 비교해보시죠!

import view.ResultView;

public class ResultViewMapper {
private final ResultView resultView;
Copy link

Choose a reason for hiding this comment

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

변환을 담당하는곳에서 resultView가 필요하다는것은 뭔가 어색하지 않았나요?🤔

단일 책임의 관점에서도 고민해보죠!

package domain.participant;

public class Balance {
public static final Balance ZERO = new Balance(0);
Copy link

Choose a reason for hiding this comment

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

0에 대한 객체는 미리 만들어서 재사용 기능하게 만들어주셨군요


private final int balance;

public Balance(int balance) {
Copy link

Choose a reason for hiding this comment

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

balance가 음수로 넘어오는 케이스는 고려하지 않아도될까요?

Comment on lines 14 to -15
private final List<Card> cards;
private int score;
Copy link

Choose a reason for hiding this comment

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

잘 변경해주셨네요 👍 👍
어떤것은 필드로 두고 어떤것은 두지 말아야하는지
앞으로도 계속 고민을 하면서 기준을 만드는게 중요하다고 생각해요! :)

@@ -25,8 +27,8 @@ public void addCardForTest(final Card card) {
hand.addCard(card);
}
Copy link

Choose a reason for hiding this comment

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

테스트를 위한 메서드가 Participant 에 있네요 🤔
테스트만을 위한 메서드가 실제 코드에 있어도 괜찮을까요?
어떤 단점이 있는지 학습해보시죠!

    public void addCardForTest(final Card card) {
        hand.addCard(card);
    }

}

public void updateBalance(Outcome outcome){
updateBalance((int) (betting.getBettingMoney() * outcome.winningCoefficient()));
Copy link

Choose a reason for hiding this comment

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

int 로 형변환 하는 이유가 궁금해요!
블랙잭일때 1.5 배를 하면 소수점이 잘리는 현상이 있을 수 있는데
돈 관련해서 누락이 있어도 괜찮을까요? 🤔

@@ -58,7 +54,19 @@ public List<Card> getCards() {
}

public HandState getHandState(){
Copy link

Choose a reason for hiding this comment

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

한가지 고민인 부분이 있어요
HandState 에 STAY 라는 개념이 없는데
그럼 참가자가 STAY 를 외쳤을때도 getHandState 에서는 HIT 상태를 반환하겠군요 🤔
상태를 올바르게 나타낸게 맞을지 고민입니다!

Comment on lines +10 to +12
public int getBettingMoney(){
return betting;
}
Copy link

Choose a reason for hiding this comment

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

클래스 이름 + 필드 이름 또는 메서드 이름을 하나로 통일해볼 수 있겠네요 🤔

클래스이름, 필드명 - Betting
메서드명 - getBettingMoney()

@@ -0,0 +1,13 @@
package domain.participant;

public class Betting {
Copy link

Choose a reason for hiding this comment

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

Betting 객체는 동일한 값을 가진 다른 객체일때 둘은 equals 하다고 비교되고 있을까요?
현실에서 1000원 지폐 두장은 일련번호로는 다르다고 볼 수 있지만
값 자체로는 1000원이라는 값 자체로는 동등한 값이라고 볼 수 있어요

아래 결과는 true 가 나오는지 실험해보시면 좋겠어요~

Betting a = new Betting(1000);
Betting b = new Betting(1000);

a.equals(b) <-- true or false?

객체간에 == 비교와 equals 비교의 차이에 대해서 학습해보고 공유해주세요!

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