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

[숫자 야구 게임] 박수현 미션 제출합니다. #286

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

Conversation

Suxxxxhyun
Copy link

1주차 숫자 야구 과제를 제출합니다.

@Suxxxxhyun Suxxxxhyun closed this Oct 24, 2023
@Suxxxxhyun Suxxxxhyun reopened this Oct 24, 2023
@Suxxxxhyun Suxxxxhyun changed the title Suxxxxhyun [숫자 야구 게임] 박수현 미션 제출합니다. Oct 24, 2023
Copy link

Choose a reason for hiding this comment

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

Controller를 4개 생성 하셨어요. 혹시 이유가 있으실까요? 궁금합니다!

Copy link
Author

Choose a reason for hiding this comment

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

움! 갯수와 상관없이 그 기능을 구현하기 위해 Controller를 많이 생성하게되었네요! 오늘 다른 사람의 코드를 보니 ValidationController같은 경우는 utils로 하여서 Controller가 아닌 부분으로 별도로 분리하더라고요! 부족해서 ㅎㅎ 4개까지 만든게 아닌가 싶네요 ㅎㅎ

Comment on lines 6 to +8
public static void main(String[] args) {
// TODO: 프로그램 구현
GameController game = new GameController();
game.proceedGame();
Copy link

Choose a reason for hiding this comment

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

4개의 Controller가 있지만 main에서는 GameController의 로직만 참조하고 있습니다.

Comment on lines +18 to +19
private static final String INPUT_NUMBER_MESSAGE = "숫자를 입력해주세요 : ";
private static final String ASK_RESET_GAME_MESSAGE = "게임을 시작하려면 1, 종료하려면 2를 입력해주세요";
Copy link

Choose a reason for hiding this comment

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

하드코딩 하지 않고 해당 클래스 내에서 상수로 관리하는 전략을 사용하셨네요. 개인적으로 좋다고 생각합니다.

Copy link
Author

Choose a reason for hiding this comment

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

@Hugh-KR ㅎㅎ!! 감사합니다!

public List<Integer> convertStringToIntList(String inputNumber){
List<Integer> playerNumbers = new ArrayList<Integer>();
for(int i=0; i<inputNumber.length(); i++){
int x = inputNumber.charAt(i) - '0';
Copy link

Choose a reason for hiding this comment

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

'0' 도 상수로 관리해 주면 좋을 듯 합니다.

Comment on lines +61 to +63
public List<Integer> convertStringToIntList(String inputNumber){
List<Integer> playerNumbers = new ArrayList<Integer>();
for(int i=0; i<inputNumber.length(); i++){
Copy link

Choose a reason for hiding this comment

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

유효성 검증 로직을 별도 클래스로 분리하신 거 정말 좋네요!

그런데 convertStringToIntList는 도메인 로직이 아닌가 생각합니다. 코드 분리를 고민해 보시면 좋을 듯 해요. 😄

Comment on lines +51 to +53
} else if (answer.equals(BASEBALL_GAME_END_ANSWER)) {
return false;
}
Copy link

Choose a reason for hiding this comment

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

저도 `객체지향 생활체조'를 공부하며 알게 된 사실인데 else 예약어를 최대한 지양하라고 말하고 있어요.

자칫하면 조건의 분기에 대한 depth가 깊어질 수 있기 때문이죠. 혹시 관심 있으시다면 찾아보시면 좋을 듯합니다. 😄

Copy link
Author

Choose a reason for hiding this comment

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

오오!! 감사합니다!

@Hugh-KR
Copy link

Hugh-KR commented Oct 26, 2023

전반적으로 꼼꼼한 테스트 코드 작성과 기능 분리를 고민했다는 느낌을 받았어요. MVC 패턴을 사용해 주셨는데 앞으로의 미션에서도 사용할 예정이라면 다시 한번 공부해 보는 것도 좋은 선택이라고 생각합니다.

1주 차 미션 정말 고생 많으셨고 2주 차 미션도 함께 화이팅 입니다. 😎

Copy link
Author

@Suxxxxhyun Suxxxxhyun 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 +51 to +53
} else if (answer.equals(BASEBALL_GAME_END_ANSWER)) {
return false;
}
Copy link
Author

Choose a reason for hiding this comment

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

오오!! 감사합니다!

@Suxxxxhyun
Copy link
Author

전반적으로 꼼꼼한 테스트 코드 작성과 기능 분리를 고민했다는 느낌을 받았어요. MVC 패턴을 사용해 주셨는데 앞으로의 미션에서도 사용할 예정이라면 다시 한번 공부해 보는 것도 좋은 선택이라고 생각합니다.

1주 차 미션 정말 고생 많으셨고 2주 차 미션도 함께 화이팅 입니다. 😎

@Suxxxxhyun Suxxxxhyun closed this Oct 26, 2023
@Suxxxxhyun Suxxxxhyun reopened this Oct 26, 2023
@Suxxxxhyun
Copy link
Author

실수로.. 닫아버렸습니다 ㅎㅎ..!

Choose a reason for hiding this comment

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

메소드를 분리하면서 예외 처리를 어떻게 해야 할지 고민하다가,
작성하신 코드에서 여러 예외를 각각의 메소드로 나눠서 처리하는 방법을 보고 많은 도움 받았습니다!

기존의 전 예외 처리 메소드 하나로 모든 예외를 처리 했었는데,

작성하신 코드처럼 예외 하나마다 별도의 메소드로 분리하는 것이 더 각 예외의 기능을 명확하게 드러내는 방법이라고 느꼈습니다.

좋은 코드 작성해주셔서 감사합니다!

Copy link
Author

Choose a reason for hiding this comment

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

칭찬 감사합니다!! 2주차도 화이팅해봐요!!


private int generateRandomNumber(List<Integer> randomNumbers) {
while (true) {
int randomNumber = Randoms.pickNumberInRange(1, 9);

Choose a reason for hiding this comment

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

위 숫자들도 상수로 관리할 수 있을 것 같아요!

Copy link
Author

Choose a reason for hiding this comment

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

그러네요! 감사합니다!


public String enterAnswerRestartGame() {
System.out.print(ASK_RESET_GAME_MESSAGE);
return Console.readLine();

Choose a reason for hiding this comment

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

사용자의 입력과 동시에 입력 받은 문자열을 리턴하신 것이 인상깊어요! 배워갑니다!

assertThat(throwable).isInstanceOf(IllegalArgumentException.class);
assertThat(throwable).hasMessage(exceptionMessage);
}
}

Choose a reason for hiding this comment

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

모든 경우에 대해 테스트하신 게 인상깊어요
저도 이번 주차부터는 테스트 함수를 작성해봐야겠어요! 코드 리뷰 통해 많이 배웠습니다!

Choose a reason for hiding this comment

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

저도 테스트 코드를 굉장히 많이 작성한게 흥미롭네요!👍🏻

Copy link
Author

Choose a reason for hiding this comment

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

테스트코드를 이번기회에 많이 공부해봤는데 도움이 되셨다니 제가 다 뿌듯하네용!!

Copy link

Choose a reason for hiding this comment

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

정말 다양한 케이스에 테스트 작성을 너무 잘하셔서 많이 학습하시고 고민하시고 노력하신게 보여요 많이 배웠습니다!!! 너무 고생하셨어요!!

return convertStringToIntList(inputNumber);
}

public boolean isTreeInput(String inputNumber){

Choose a reason for hiding this comment

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

만약 야구 게임이 3자리의 수가 아닌 다른 수로 진행한다고 바뀌었을 때, 함수명까지 바꿔야하는 상황이 발생할 수 있으니ㅎㅎ 함수명은 조금 더 추상적인 이름이 좋을 것 같습니다

Copy link
Author

Choose a reason for hiding this comment

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

@wonchanjoo 오! 그러네요!! 앞으로도 그러한 상황까지 고려하여서 작성해봐야겠네요! 감사합니다!

Comment on lines +73 to +77
private void validationPlayer(){
gameNumber.setPlayerInput(inputView.inputNumber());
List<Integer> playerNumbers = validation.validate(gameNumber.getPlayerInput());
gameNumber.setPlayerNumbers(playerNumbers);
}

Choose a reason for hiding this comment

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

함수 이름만 봤을 때 플레이어가 입력한 수를 예외 처리 하는 함수인가? 싶었는데 플레이어가 입력한 수를 저장하는 함수인 것 같아서 약간 의아하다는 생각이 들었습니다

Copy link
Author

Choose a reason for hiding this comment

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

@wonchanjoo 함수 이름을 좀 더 생각해서 작성해봐야겠네요..!! 답변 감사합니다!

Copy link

@shimbaa shimbaa left a comment

Choose a reason for hiding this comment

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

리뷰남겨주셔서 감사합니다 😁 제가 리뷰를 작성해보는게 처음이라 부족하지만
서로 코드를 보며 배워가는게 정말 도움이 많이 된다는 것을 느꼈어요 많이 배웠습니다 감사합니다!

gameNumber.setComputerNumbers(computerNumbers);
}

public boolean threeStrike(GameNumber gameNumber){
Copy link

Choose a reason for hiding this comment

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

threeStrike 인지 여부를 확인하는 메서드라면 isThreeStrike 와 같은 네이밍은 어떨까 생각해봅니다!

outputView.printMessage(message);
}

public String getNotingHintMessage(){
Copy link

Choose a reason for hiding this comment

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

저도 출력 부분에 대해서 고민이 많았는데, 출력 형식을 만드는 부분을 따로 빼서 클래스를 만드는 것은 어떻게 생각하시나요?
예를 들어 ballCount와 strikeCount를 파라미터로 받아서 처리하는 방식으로요!

return inputNumber.length() == THREE_LENGTH;
}

public boolean isRange(String inputNumber){
Copy link

Choose a reason for hiding this comment

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

유효한 숫자 범위를 검증하는 것이라고 생각하면 isValidRange 가 조금더 명확한 이름일 수도 있을 거 같아요..!
그리고 저도 리뷰를 받았던 부분인데 추후에 정규표현식을 적용해보는 것도 생각해볼 수 있을거 같아요!

* -----------------------------------------------------------
* 2023-10-19 qkrtn_ulqpbq2 최초 생성
*/
public class ComputerTest extends NsTest {
Copy link

Choose a reason for hiding this comment

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

와 테스트 작성 너무 잘하신거같아요!!!
주어진 NsTest 라이브러리 활용하신거도 너무 인상적이네요 멋져요

assertThat(throwable).isInstanceOf(IllegalArgumentException.class);
assertThat(throwable).hasMessage(exceptionMessage);
}
}
Copy link

Choose a reason for hiding this comment

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

정말 다양한 케이스에 테스트 작성을 너무 잘하셔서 많이 학습하시고 고민하시고 노력하신게 보여요 많이 배웠습니다!!! 너무 고생하셨어요!!

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.

6 participants