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단계 - 블랙잭 게임 실행] 망쵸(김주환) 미션 제출합니다. #2

Open
wants to merge 56 commits into
base: main
Choose a base branch
from

Conversation

3Juhwan
Copy link
Member

@3Juhwan 3Juhwan commented Mar 8, 2024

안녕하세요~

페어 땡이와 함께 열심히 미션을 진행했어요. 저는 페어 프로그래밍 과정에서 얻을 수 있는 소프트 스킬 역량에 집중하는 편인데요! "함께 즐겁게 코딩하자"가 저의 목표랍니다. 그래서 1단계 미션 코드에 부족함이 여실 없이 드러나네요 😓
그래도 코드 한 줄 한 줄 고민하고 토론하며 작성했어요. 좋은 피드백, 따끔한 피드백 모두 감사합니다. 😀

3Juhwan and others added 30 commits March 5, 2024 15:22
Co-authored-by: MangCho <[email protected]>
Co-authored-by: J-I-H-O <[email protected]>
Co-authored-by: MangCho <[email protected]>
Co-authored-by: J-I-H-O <[email protected]>
Co-authored-by: MangCho <[email protected]>
Co-authored-by: J-I-H-O <[email protected]>
Co-authored-by: MangCho <[email protected]>
Co-authored-by: J-I-H-O <[email protected]>
Co-authored-by: MangCho <[email protected]>
Co-authored-by: J-I-H-O <[email protected]>
Co-authored-by: MangCho <[email protected]>
Co-authored-by: J-I-H-O <[email protected]>
Co-authored-by: MangCho <[email protected]>
Co-authored-by: J-I-H-O <[email protected]>
Co-authored-by: MangCho <[email protected]>
Co-authored-by: J-I-H-O <[email protected]>
Copy link
Member

@seokmyungham seokmyungham 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 16 to 19
for (final CardNumber cardNumber : CardNumber.values()) {
for (final CardShape cardShape : CardShape.values()) {
deck.push(new Card(cardNumber, cardShape));
}
Copy link
Member

Choose a reason for hiding this comment

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

indent를 1까지만 허용한다는 요구 사항이 있기도 하니까 메서드를 분리해보는 건 어떨까요?
아니면 Stream을 사용하는 것도 방법일 것 같습니다. 😄

import java.util.Stack;

public class CardDeck {
private final Stack<Card> deck;
Copy link
Member

Choose a reason for hiding this comment

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

많은 자료구조 중에 Stack을 선택하신 이유가 궁금합니다!!

import blackjack.domain.card.Card;

public class Dealer extends Player {
private static final String NAME = "딜러";
Copy link
Member

Choose a reason for hiding this comment

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

망쵸~ 저도 이렇게 Dealer 안에 상수로 "딜러"라고 정의하도록 구현했었어요.
그런데 이와 관련해서 리뷰어분께 리뷰를 받게 되었습니다.

리뷰 내용은

  • 딜러에게 굳이 이름이 필요할까요?
  • 입력과 관련없는 "딜러" 라는 딜러의 이름을 표현하는 책임은, 딜러가 맞을까요?

망쵸는 이와 관련해서 어떻게 생각하시나요~? 😊

Comment on lines 20 to 22
if (minimumSum + 10 <= 21) {
minimumSum += 10;
}
Copy link
Member

Choose a reason for hiding this comment

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

상수 분리의 필요를 TODO로 남겨 놓으셨군요!!
그런데 놓치신 것 같으니 제가 한 번더 리뷰로 알려드리겠습니다 ㅎㅎㅎ 😄

다른 개발자가 이 코드를 처음 보게되었을 때,
저 10을 바로 이해할 수 있을지 고민해보셔도 좋을 것 같아요 !

Comment on lines +19 to +22
final String errorMessage = String.format("[ERROR] 이름의 길이는 %s 이상, %s 이하여야 합니다.",
MINIMUM_LENGTH, MAXIMUM_LENGTH);
throw new IllegalArgumentException(errorMessage);
}
Copy link
Member

Choose a reason for hiding this comment

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

저도 이렇게 상수를 활용해서 에러 메시지를 구체화 하는거 정말 좋아합니다 😊

Comment on lines 19 to 25
public void initializeHand(final Dealer dealer, final List<Player> players) {
giveCard(dealer);
giveCard(dealer);
giveTwoCardsEachPlayer(players);
}

private void giveTwoCardsEachPlayer(final List<Player> players) {
Copy link
Member

@seokmyungham seokmyungham Mar 10, 2024

Choose a reason for hiding this comment

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

파라미터로 넘긴 값을 변경하지 않도록 수정해야할 것 같은데 망쵸는 어떻게 생각하시나요??

현재 값의 변경 책임이 참조로 전달된 파라미터 객체 외부에 있다는 생각이 듭니다.
이러면 final 키워드를 사용하는 의미도 퇴색된다고 생각하고
디버깅도 어려울 뿐만 아니라 유지보수 하기 힘들어질 것이라 생각해요.

Copy link
Member

Choose a reason for hiding this comment

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

가장 단순하게 제 생각에는 CardGameDealer를 갖고 있도록 변경하거나 아니면 파라미터 객체에 직접 책임을 지도록 하는 방법이 있을 것 같아요.

players는 일급 컬렉션이 따로 존재하지 않으니 메서드 지역변수로 생성해서 반환하는 방법이 존재할 것 같습니다.

Copy link
Member

@robinjoon robinjoon 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 93 to 103
void 카드_합계가_딜러와_플레이어_모두_21_이하인_경우_숫자가_큰_사람이_승리한다() {
CardGameJudge cardGameJudge = new CardGameJudge();

Player player = player(new Card(ACE, HEART));
Dealer dealer = dealer(new Card(KING, SPADE));

var result = cardGameJudge.judge(dealer, List.of(player))
.getTotalResult();

assertThat(result.get(player)).isEqualTo(WinningStatus.LOSE);
}
Copy link
Member

Choose a reason for hiding this comment

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

image 테스트 터져요!! 😭

Comment on lines +4 to +5
HIT("y"),
STAND("n");
Copy link
Member

Choose a reason for hiding this comment

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

[질문] y, n 이라는 문자는 view의 관심사 같아요. view가 변경되면 같이 변경되어야 하는데, 대안은 없을까요?

Comment on lines 14 to 25
@Test
void 가진_패의_숫자의_합계를_구할_수_있다() {
Hand hand = new Hand();
hand.add(new Card(JACK, SPADE));
hand.add(new Card(QUEEN, SPADE));
hand.add(new Card(KING, SPADE));

int sum = hand.getSum();

assertThat(sum).isEqualTo(30);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

[의견] Ace를 처리하는 부분은 테스트가 수행되지 않네요!

Comment on lines +15 to +26
@Test
void 플레이어는_죽었는지_여부를_반환한다() {
Player player = player(
new Card(KING, CLOVER),
new Card(KING, SPADE),
new Card(KING, HEART));

boolean isAlive = player.isAlive();

assertThat(isAlive).isFalse();
}
}
Copy link
Member

Choose a reason for hiding this comment

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

[의견] 플레이어가 죽는 시점은 합이 22가 되었을 때 입니다. 이 테스트는 합이 30이 되었을 때 죽는지 확인하는 것이므로, 22 ~ 29 에서 플레이어가 죽는지 알 수 없습니다!

Copy link
Member

Choose a reason for hiding this comment

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

다른 테스트 코드에서도 마찬가지로 경계값 테스트가 수행되지 않고 있습니다!

Copy link
Member

@hyxrxn hyxrxn left a comment

Choose a reason for hiding this comment

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

흐름은 이해가 잘 되는 코드라고 생각해요!
다만 메서드 라인 제한, indent 제한 등 요구사항이 지켜지지 않은 부분이 종종 보이네요.
일단 요구사항이 있다면 잘 지켜야 한다고 생각합니다!
그리고 테스트에서 클래스 다음 줄이 공백인 경우도 있고, 아닌 경우도 있는데 규칙을 정해 통일하면 더 보기 좋겠네요!

Comment on lines 3 to 11
import blackjack.domain.cardgame.CardGame;
import blackjack.domain.cardgame.CardGameJudge;
import blackjack.domain.cardgame.CardGameResult;
import blackjack.domain.player.Dealer;
import blackjack.domain.player.Player;
import blackjack.view.InputView;
import blackjack.view.OutputView;

import java.util.List;
Copy link
Member

Choose a reason for hiding this comment

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

구글 자바 컨벤션에서는 non static import 사이에 엔터가 없는 게 규칙이더라구요~~~

Comment on lines 4 to 7
SPADE("스페이드"),
HEART("하트"),
DIAMOND("다이아몬드"),
CLOVER("클로버");
Copy link
Member

Choose a reason for hiding this comment

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

출력 형식이 하트에서 HEART로 변경되면 도메인이 함께 바뀌어야 하네요.
이 부분은 View의 역할 아닐까요?
CardNumber과 WinningStatus도 마찬가지 의견입니다!

}

private static String getCardInfo(final Card card) {
return card.getNumber() + card.getShape();
Copy link
Member

Choose a reason for hiding this comment

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

getNumber를 하면 getValue를 하고, j, q, k의 value는 모두 10이군요...!
에이스 또한 a로 출력되지 않고 1로 출력됩니다.

Comment on lines 19 to 23
public void initializeHand(final Dealer dealer, final List<Player> players) {
giveCard(dealer);
giveCard(dealer);
giveTwoCardsEachPlayer(players);
}
Copy link
Member

Choose a reason for hiding this comment

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

딜러에게 두장을 주는 부분은 그대로 두고 플레이어들에게 두장 주는 부분은 메서드로 따로 뺀 이유가 있나요?
그리고 initializeHand라는 메서드명으로는 두 장씩 준다는 것을 모를 수 있을 것 같은데 어떻게 생각하시나요?!

Comment on lines 18 to 22
final int aceCount = getAceCount();
for (int i = 0; i < aceCount; i++) {
if (minimumSum + 10 <= 21) {
minimumSum += 10;
}
Copy link
Member

Choose a reason for hiding this comment

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

에이스가 4장 있어도 한 장만 10점을 더할 수 있는데, 그러면 의미없는 for문을 세 번 더 돌게 되네요!

Comment on lines 45 to 46
}
public static void printPlayerCardWithScore(final Player player) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
}
public static void printPlayerCardWithScore(final Player player) {
}
public static void printPlayerCardWithScore(final Player player) {

공백이 없습니다

Comment on lines 27 to 28
final String initialDistributionMessage = String.format("%s와 %s에게 2장을 나누었습니다.", dealer.getName(), names);
System.out.println(initialDistributionMessage);
Copy link
Member

Choose a reason for hiding this comment

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

printf를 사용하면 될 듯 한데... 다른 메서드들도 그렇고 출력 부분을 변수설정 + 출력 이렇게 두 줄로 나눠서 출력하는 이유는 무엇인가요?
String 변수를 따로 이름 붙이는 것이 가독성이 좋다고 생각해서인가요?
아니면 다른 이유가 있을까요?

Comment on lines 23 to 31
private static void printPlayerNamesInputMessage() {
System.out.println("게임에 참여할 사람의 이름을 입력하세요.(쉼표 기준으로 분리)");
}

private static void printAskingForAnotherCardMessage(final String name) {
printLineSeparator();
System.out.println(name + "는 한장의 카드를 더 받겠습니까?(예는 " + HIT.getMessage() +
", 아니오는 " + STAND.getMessage() + ")");
}
Copy link
Member

Choose a reason for hiding this comment

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

InputView에 print로 시작하는 메서드가 있는 것이 조금 어색하네요.
저는 이 또한 출력에 해당한다고 생각해 OutputView에 넣었는데, 이 부분에 대해 망쵸는 어떻게 생각하나요?

this.message = message;
}

static boolean isDrawable(final String choice) {
Copy link
Member

Choose a reason for hiding this comment

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

메서드명만 보면 isAlive와 비슷한 역할을 할 것 같아요!

Comment on lines 4 to 5
import blackjack.domain.cardgame.CardGameJudge;
import blackjack.domain.cardgame.WinningStatus;
Copy link
Member

Choose a reason for hiding this comment

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

사용하지 않는 import가 있네요... ㅎㅎ
인텔리제이에 이것도 자동으로 정리해주는 기능이 있는 것으로 아는데 사용을 추천합니닷

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.

4 participants