-
Notifications
You must be signed in to change notification settings - Fork 388
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단계 - 블랙잭(베팅)] 테오(최우성) 미션 제출합니다. #527
Conversation
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단계도 잘 구현해주셨네요 테오 👍🏻
몇가지 리뷰 남겼으니 한번 더 확인해주세요 💪🏻
질문 주신 부분은 코멘트로 남기겠습니다!
List<Card> shuffledCards = new ArrayList<>(cards); | ||
Collections.shuffle(shuffledCards); | ||
return shuffledCards; |
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.
자명한 라이브러리 이외의 로직이 추가되었으니 테스트가 필요해보입니다!
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.
저는 내부적으로 로직이 추가되었기는 하나, 단순히 생성 흐름이라 판단해서
테스트할 것이 없다고 생각했었습니다. 또한 무엇을 테스트해야 할지도 명확하지가 않다고 생각했어요.
고민해보았는데, 말씀해주신 부분에 대해 아직 제가 감을 잘 못잡는 것 같습니다 😅
혹시 조금만 더 짚어주실 수 있을까요!?
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.
기존엔 Collections.shuffle(shuffledCards)
로만 구성된 메서드였지만,
현재는 새로운 리스트를 생성해서 반환하는 테오만의 로직이 추가되었으니 이 부분에 대한 테스트가 필요하지 않을까요? 라는 리뷰였습니다. 예를들어 입력한 리스트와 반환된 리스트가 동일한 레퍼런스를 갖지 않는 테스트가 존재할 수 있겠네요!
private static final int NUMBERS_OF_CARDS_TO_HIDE = 1; | ||
private static final int DEPOSIT = 100_000; | ||
|
||
private static final String DEFAULT_NAME = "딜러"; |
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.
이전에 드렸던 리뷰에 공감되서 옮기신 거라면 플레이어의 이름 검증 부분이 추가되어야하지 않을까요? 그렇게되면 이 상수는 어디에 위치하는게 적절할까요?
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.
고민해 본 결과,
터틀이 말씀해주신 의도가 예약어이기 때문에 플레이어가 이를 사용할 수 없게 해야 한다
임을 알았습니다. (맞겠죠..?!)
즉, 플레이어 이름을 향한 검증 로직이 '딜러'라는 예약어와 함께 존재해야 하고,
결국 '딜러'라는 리터럴은 PlayerName
객체에 존재해야 한다라는 결론에 도달했습니다.
하지만 '딜러'라는 이름이 PlayerName 객체에 존재하게 되면 Dealer는 더 이상 생성자를 통해 이름을 초기화할 수 없습니다.
따라서 protected 생성자를 정의하고, Dealer가 호출 가능하게 정의했습니다.
이 과정에서 PlayerName까지 생성자가 추가되었는데, 이런 접근방식은 처음이라 좋은 설계인지 궁금합니다!
그리고, 리터럴 상수로 "딜러"만 정의해두고 검증에서 이를 사용하는 것은 확장에 닫혀있다 생각하여 enum 객체로 분리하였는데 이것도 괜찮은 방법이었는지 궁금해요 🙇♂️
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.
많은 고민을 해주셨군요 👍🏻
간단히 PlayerName
을 GameParticipantName
로 바꾸면 구현이 가능하지 않을까요? 🙂
질문 주셨을때 코드를 기준으로는 정답이 없는 부분 같아요. 각 방법의 장단점을 인지한 채로 테오가 선호되는 방향으로 반영해주시면 될것같아요. 하지만 지금의 코드 기준으로는 2단계 구현으로 인해 Player의 의존이 이미 생겨버렸네요! 그럼에도 불구하고 GameParticipant의 책임이 적절하다고 생각하신다면 반영 안해주셔도 무방합니다 😊 |
정답이 없는 부분이군요.. 말씀주신대로 이미 Player 의존이 존재하기도 하고, 저는 터틀이 제시해주신 방식이 좋다고 생각하여 유지할 예정입니다! 답변 감사합니다 터틀 👍 |
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단계 구현 완료했습니다.
기능이 추가됨에 따라 기존 구조에서 크게 바뀐 점은 없는데요,
자력으로 해결할 수 없는 궁금증을 몇가지 여쭙고 싶습니다.
의존성
저번에 리뷰해주셨던 내용 중, 다음과 같은 내용이 있었습니다.
![image](https://user-images.githubusercontent.com/78679830/224471463-c62c1c57-b0e8-4b6d-9310-61a94e201e91.png)
저도 터틀 말씀에 동의해 의도하신대로 코드 구조를 바꿨지만, 다음과 같은 궁금증이 생겼습니다.
바뀐 코드에서는
BlackjackGame
이Player
객체를 알게 됩니다. 그러나 이전 코드에서는BlackjackGame
이GameParticipant
만 알면 되었습니다. 즉, 변경을 통해 보다 좋은 흐름은 가지게 되었으나,BlackjackGame
에 의존성이 하나 더 추가되었습니다.어느 방법이 좋은 방법인지 아직 잘 모르겠지만,
Player가 자주 변화하는 도메인이라면 이전방법처럼 BlackjackGame에서 의존성을 분리하는게 맞을거라 생각하는데, 터틀도 그렇게 생각하시는지 궁금합니다.
이외에도 부족한 부분이 많으니 피드백 마구마구 해주시면 감사하겠습니다. 👍