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

[2단계 - 블랙잭 베팅] 루키(김준하) 미션 제출합니다. #886

Open
wants to merge 72 commits into
base: junhaa
Choose a base branch
from

Conversation

junhaa
Copy link

@junhaa junhaa commented Mar 14, 2025

안녕하세요 엘리 😀

이번 step2 미션에서는 기존에 사용하던 상속을 조합으로 변경해봤어요.
조합으로 사용하는 것이 익숙하지 않아서 맞는 방법으로 사용했는지 궁금해요.

이번 미션도 잘부탁드려요! 😃

체크 리스트

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

객체지향 생활체조 요구사항을 얼마나 잘 충족했다고 생각하시나요?

1~5점 중에서 선택해주세요.

  • 1 (전혀 충족하지 못함)
  • 2
  • 3 (보통)
  • 4
  • 5 (완벽하게 충족)

선택한 점수의 이유를 적어주세요.

  • 한 줄에 점을 여러 개 사용한 경우가 있습니다.
  • 모든 엔티티를 작게 유지하지 못했습니다.

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

1️⃣ 이름을 사용하여 처리하는 로직

현재 코드에서는 대부분 Participants에 이름을 전달하여 객체에게 메세지를 전달하고 있는데요. 처음에는 객체를 넘기는 방법이 오히려 위험하다고 생각했지만, 불변성을 보장한다면 객체 자체를 넘기는 게 더 나은 방법일지 궁금해요. 이름을 전달하게 된다면, Participants내부에서도 이름을 통해 원하는 객체를 찾아야 한다는 점이 오히려 절차적인 프로그래밍 방식 같다는 생각이 들었어요.

2️⃣ 객체의 생성을 어디서 해야 하는지

이번 미션을 하면서 객체를 생성해서 생성자에 넘겨주는 것과 원시값을 생성자에 전달하여 생성자 내부에서 생성하는 것을 고민했어요. 우선 현재 코드에서는 원시값을 생성자에 전달하는 방식을 사용하고 있어요. 제가 생각하기에는 객체를 생성해서 넘겨주는 경우, 객체의 내부에서 변경이 이루어져도 객체 자체를 넘기기 때문에 수정할 사항이 줄어든다고 생각했어요. 반대로 원시값을 생성자에 전달하는 경우에는 내부적으로 객체를 생성하기 때문에 외부에서 접근할 필요가 없어 캡슐화가 된다는 장점이 있다고 생각했어요. 두 방법 중 제가 아직 고민해보지 못한 부분이 있는 지 궁금해요.

praisebak added 30 commits March 4, 2025 15:11
원래는 카드 뽑기 정책 테스트였으나, 더 작은 단위가 생겨서 카드 생성 테스트부터 다시 시작하였습니다
동일한 논리로 CardTest -> DeckTest로 옮겨갔습니다
카드 덱의 의도를 나타내기에 deque가 더 낫다고 판단하였습니다
중복 코드를 위해 상속을 사용하는것은 지양해야하지만 완전한 is-A 관계이기 때문에 도입해도 상관없을 것이라 판단하였습니다
junhaa added 24 commits March 10, 2025 15:07
- Blackjackparticipant 클래스에 대한 테스트 분리
- Blackjack에 대한 클래스임이 명확하기 때문에 제거하여 클래스 이름을 간결하게 변경
- static 메서드를 이용해서 사용하기 보다는 Hand에서 플레이어의 점수를 비교하여 승패를 반환
- GameJudge 클래스의 승패 담당 로직 WinStatus Enum으로 이동
- 이름이 중복되는 경우 예외 발생
- 딜러의 이름을 사용하는 경우 예외 발생
@junhaa junhaa force-pushed the step2 branch 2 times, most recently from 2be6652 to 5934b26 Compare March 14, 2025 19:40
Copy link

@yebink yebink left a comment

Choose a reason for hiding this comment

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

안녕하세요 루키~

2단계도 잘 구현하셨네요! 👏
몇 가지 피드백 남겨두었으니 확인해보세요!

@@ -30,8 +27,10 @@ public BlackjackController(InputView inputView, OutputView outputView) {

public void run() {
List<String> names = handleInput(this::handleNames);
List<Integer> betAmounts = inputBetAmounts(names);
Deck deck = DeckGenerator.generateDeck(new BlackjackDrawStrategy());
Copy link

Choose a reason for hiding this comment

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

DeckGenerator 에서는 Deck 의 생성만을 담당하고 있네요.
응집도를 높이기 위해 Deck 생성은 Deck 에서 직접 해볼까요?


private static final String DEALER_NAME = "딜러";
private static final Score DEALER_STOP_HIT_STANDARD_SCORE = Score.from(16);
private final Participant participant;
Copy link

Choose a reason for hiding this comment

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

조합을 잘 활용하셨네요 👍

상속에 비해 어떤 장점이 있었나요~?

import java.util.List;

public abstract class HandState {
private static final Score MAX_SCORE = Score.from(21);
Copy link

Choose a reason for hiding this comment

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

ParticipantHandBUST_STANDARD_SCORE와 동일한 값인데요! 합쳐 볼까요? 🤔

Comment on lines +47 to +50
IntStream.range(0, names.size())
.forEach(index -> {
players.add(new Player(names.get(index), playerBets.get(index), drawInitCard(deck)));
});
Copy link

Choose a reason for hiding this comment

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

namesplayerBets 의 인덱스가 같으면 동일 참가자라고 판단하고 있는데요!
createPlayers 메서드 입장에서 두 List에 변경이 없음을 보장할 수 없을 것 같네요.

playerBetsMap<이름, 베팅금액> 과 같이 명시적으로 나타내볼까요?

}
}

private TrumpCard[] drawInitCard(Deck deck) {
Copy link

Choose a reason for hiding this comment

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

List 는 장점이 많은 자료구조입니다.
Array [] 와 가변인자 ... 는 꼭 필요한 경우가 아니라면 제거하고 List 로 대체해볼까요?

@yebink
Copy link

yebink commented Mar 15, 2025

1️⃣ 이름을 사용하여 처리하는 로직
동의합니다~ String 보다는 ParticipantName 을 사용하는 것이 더 안전해보여요 👍

2️⃣ 객체의 생성을 어디서 해야 하는지
객체를 생성해서 생성자에 넘겨주는 것 은 객체가 생성되기 위해 필수적으로 다른 객체가 필요하다는 건데요!
이는 객체 간 강결합이 발생할 수도 있겠네요. (Deck과 DeckGenerator처럼요)
저는 객체 생성자에서 생성되는 것이 자연스러워 보입니다 😄
지금은 말씀하신 두 가지 방식 내에서 고민해보셔도 충분할 것 같네요!

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