-
Notifications
You must be signed in to change notification settings - Fork 467
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
base: junhaa
Are you sure you want to change the base?
Conversation
원래는 카드 뽑기 정책 테스트였으나, 더 작은 단위가 생겨서 카드 생성 테스트부터 다시 시작하였습니다
동일한 논리로 CardTest -> DeckTest로 옮겨갔습니다
카드 덱의 의도를 나타내기에 deque가 더 낫다고 판단하였습니다
중복 코드를 위해 상속을 사용하는것은 지양해야하지만 완전한 is-A 관계이기 때문에 도입해도 상관없을 것이라 판단하였습니다
- Blackjackparticipant 클래스에 대한 테스트 분리
- Blackjack에 대한 클래스임이 명확하기 때문에 제거하여 클래스 이름을 간결하게 변경
- static 메서드를 이용해서 사용하기 보다는 Hand에서 플레이어의 점수를 비교하여 승패를 반환
- GameJudge 클래스의 승패 담당 로직 WinStatus Enum으로 이동
- 이름이 중복되는 경우 예외 발생 - 딜러의 이름을 사용하는 경우 예외 발생
2be6652
to
5934b26
Compare
There was a problem hiding this 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()); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ParticipantHand
의 BUST_STANDARD_SCORE
와 동일한 값인데요! 합쳐 볼까요? 🤔
IntStream.range(0, names.size()) | ||
.forEach(index -> { | ||
players.add(new Player(names.get(index), playerBets.get(index), drawInitCard(deck))); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
names
와 playerBets
의 인덱스가 같으면 동일 참가자라고 판단하고 있는데요!
createPlayers
메서드 입장에서 두 List에 변경이 없음을 보장할 수 없을 것 같네요.
playerBets
를 Map<이름, 베팅금액>
과 같이 명시적으로 나타내볼까요?
} | ||
} | ||
|
||
private TrumpCard[] drawInitCard(Deck deck) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
List 는 장점이 많은 자료구조입니다.
Array []
와 가변인자 ...
는 꼭 필요한 경우가 아니라면 제거하고 List 로 대체해볼까요?
1️⃣ 이름을 사용하여 처리하는 로직 2️⃣ 객체의 생성을 어디서 해야 하는지 |
안녕하세요 엘리 😀
이번 step2 미션에서는 기존에 사용하던 상속을 조합으로 변경해봤어요.
조합으로 사용하는 것이 익숙하지 않아서 맞는 방법으로 사용했는지 궁금해요.
이번 미션도 잘부탁드려요! 😃
체크 리스트
test
를 실행했을 때, 모든 테스트가 정상적으로 통과했나요?객체지향 생활체조 요구사항을 얼마나 잘 충족했다고 생각하시나요?
1~5점 중에서 선택해주세요.
선택한 점수의 이유를 적어주세요.
어떤 부분에 집중하여 리뷰해야 할까요?
1️⃣ 이름을 사용하여 처리하는 로직
현재 코드에서는 대부분
Participants
에 이름을 전달하여 객체에게 메세지를 전달하고 있는데요. 처음에는 객체를 넘기는 방법이 오히려 위험하다고 생각했지만, 불변성을 보장한다면 객체 자체를 넘기는 게 더 나은 방법일지 궁금해요. 이름을 전달하게 된다면,Participants
내부에서도 이름을 통해 원하는 객체를 찾아야 한다는 점이 오히려 절차적인 프로그래밍 방식 같다는 생각이 들었어요.2️⃣ 객체의 생성을 어디서 해야 하는지
이번 미션을 하면서 객체를 생성해서 생성자에 넘겨주는 것과 원시값을 생성자에 전달하여 생성자 내부에서 생성하는 것을 고민했어요. 우선 현재 코드에서는 원시값을 생성자에 전달하는 방식을 사용하고 있어요. 제가 생각하기에는 객체를 생성해서 넘겨주는 경우, 객체의 내부에서 변경이 이루어져도 객체 자체를 넘기기 때문에 수정할 사항이 줄어든다고 생각했어요. 반대로 원시값을 생성자에 전달하는 경우에는 내부적으로 객체를 생성하기 때문에 외부에서 접근할 필요가 없어 캡슐화가 된다는 장점이 있다고 생각했어요. 두 방법 중 제가 아직 고민해보지 못한 부분이 있는 지 궁금해요.