-
Notifications
You must be signed in to change notification settings - Fork 384
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단계 리뷰요청입니다 #56
Conversation
feat: 딜러와 유저의 승패를 판단하는 기능 구현 및 테스트 코드 작성
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.
안녕하세요, 서브웨이!
열심히 작성해 주신 만큼 열심히 리뷰해 보았습니다ㅎㅎ
확인 부탁드립니다:)
return Singleton.instance; | ||
} | ||
|
||
public Players createPlayers(Cards cards, List<String> playerNames) { |
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.
이 메서드를 static으로 만들어 사용하면 어떨까요?
private static class Singleton { | ||
private static final PlayerFactory instance = new PlayerFactory(); | ||
} | ||
|
||
public static PlayerFactory getInstance() { | ||
return Singleton.instance; | ||
} |
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.
아래 메서드가 static이 된다면 이 부분은 제거해도 괜찮아 보입니다.
src/main/java/domain/card/Cards.java
Outdated
public Cards() { | ||
this.cardsDeck = Card.getCards(); | ||
} | ||
|
||
public Card pop() { | ||
validateCardsDeck(); | ||
Collections.shuffle(cardsDeck); |
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.
네! 생성할때 한번만 섞도록 하는게 맞는것 같습니다!
src/main/java/domain/card/Card.java
Outdated
} | ||
} | ||
|
||
private Card(CardNumber cardNumber, CardSuitSymbol cardSuitSymbol) { |
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.
사소한 부분을 캐치하지 못했네! 변경했습니다.
import domain.card.Card; | ||
import domain.card.Cards; | ||
|
||
public class Dealer extends 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.
딜러가 Player 를 상속받는건 어감이 이상합니다. User or Man 과 같은 추상적 용어는 어떨까요?
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.
딜러도 플레이 하는 사람이라 생각해서 player 라고 했는데 Man이 어감이 더 맞는 것 같습니다.
import domain.card.Card; | ||
import domain.card.Cards; | ||
|
||
public class User extends 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.
User가 Player를 상속하는게 객체지향적으로 더 적절해 보이는데 어떻게 생각하시나요?
@@ -0,0 +1,13 @@ | |||
package dto; | |||
|
|||
public class RequestAnswerDTO { |
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.
RequestAnswerDTO => Answer로 바꾸는건 어떨까요?
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class RequestPlayerNameDTO { |
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.
RequestPlayerNameDTO => PlayerName
import java.util.*; | ||
import java.util.stream.Collectors; | ||
|
||
public class ResponseWinningResultDTO { |
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.
WinningPlayerResult로 명명을 바꾸는건 어떨까요?
public List<String> getWinningResult() { | ||
int allUserWinCount = (int) winningPlayer.values().stream().filter(win -> win).count(); | ||
int allUserLoseCount = winningPlayer.values().size() - allUserWinCount; | ||
List<String> result = new ArrayList<>(Collections.singletonList("딜러: " + allUserLoseCount + "승 " |
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.
"딜러: " + allUserLoseCount + "승 " + allUserWinCount + "패")과 같은 플러스 처리 보다는 String.fomat() 함수를 이용해 보는게 좋아보입니다.
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.
수정했습니다!
1.객체의 상속 구조를 고려해 객체의 nameing 변경 2.DTO naming 변경 3.Factory의 creat 메소드 static 변경으로 불필요한 코드 제거
dto 제거후 책임을 부여해 해당 필드를 담당하는 객체로 변경 하였습니다
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.
서브웨이~ 리뷰 반영하시느라 고생하셨습니다. 👍
몇 가지 추가 코멘트 남겼습니다. 확인 부탁드려요~!
OutputView.printInitialResult(playersName.getPlayerName()); | ||
|
||
Users users = new Users(cards, playersName.getPlayerName()); | ||
UsersInformation usersInformation = new UsersInformation(users); |
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.
UsersInformation => UsersInformations가 맞아보입니다.
users.add(new Dealer(cards.giveCard(), cards.giveCard())); | ||
} | ||
|
||
public Dealer getDealer() { |
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.
딜러를 따로 저장해 두는게 좋지 않을까요?
딜러를 찾기위해 매번 반복문이 들어가는군요.
return usersInformation.get(DEALER_INDEX); | ||
} | ||
|
||
public List<UserInformation> getPlayerInformation() { |
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.
여기도 딜러가 아닌것을 위한 불필요한 반복문 연산이 들어갑니다.
|
||
public class BlackjackController { | ||
|
||
public static void run() { |
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.
컨트롤러가 많은 코드를 들고 복잡해 보입니다.
run()만 남겨두고 다른 메서드들은 각자의 도메인에 위임시켜주세요:)
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.
고생하셨습니다 서브웨이 👍
많이 개선되었지만 네이밍, 컨벤션이 아쉬운 부분이 있어서
한번 더 확인 부탁드립니다:)
Players players = new Players(cards, playersName.getPlayerName()); | ||
|
||
OutputView.printUserCard(dealer.getName(),dealer.cardToString()); | ||
for(Player player:players.getPlayers()){ |
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.
여기 컨벤션을 34번줄과 같이 일치시켜주도록 해주세요:)
다른 부분들도 모두 부탁드립니다.
result(players, dealer); | ||
} | ||
|
||
private void userService(Cards cards, Player 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.
메서드명이 명확하지 않습니다. startGame()과 같이 변경해 보는건 어떨까요?
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.
run() {
readyGame()
startGame()
resultGame()
}
위와 같은 식으로 메서드를 정리해도 좋을 것 같습니다. 아니면 본인이 더 옳다고 생각하는 방향으로 정리해도 좋습니다.
} | ||
} | ||
|
||
private void DealerService(Cards cards, Dealer dealer) { |
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.
DealerService도 DealerTurn or dealByDealer 와 같이 뭔가 행위를 묘사해 주세요.
} | ||
} | ||
|
||
|
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.
컨벤션
} | ||
|
||
private static void validateAnswer(String answer) { | ||
if (!answer.equals("y") && !answer.equals("n")) { |
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.
상수가 조건 앞에 명시되어야 합니다.
!"y".equals(answer)
와 같이요. NPE를 예방하는 습관으로 이펙티브 자바와 같은 책에 명시되어 있는 내용입니다ㅎㅎ
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.
리뷰 반영하시느라 고생하셨습니다. 머지할게요~!
안녕하세요 리뷰어님 아직 리팩토링이 안된 동작만하는코드만 만들어서
리뷰해주시기전까지 refactoring끝내겠습니다!