-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: main
Are you sure you want to change the base?
Conversation
…ndomNumberGenerator 테스트 추가
private GameStatus initRacingCars() { | ||
ReadRacingCarsNameDto dto = ioViewResolver.resolveInputView(ReadRacingCarsNameDto.class); | ||
MovingCarNumberGenerator generator = new StandardMovingCarRandomNumberGenerator(MOVE_MIN_VALUE, MOVE_MAX_VALUE); | ||
racingGame = new RacingGame(dto.getRacingCarsName(), generator); |
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.
RacingGame
생성자의 인자에 dto
에서 값을 꺼내서 전해주는 것이 좋나요? 아니면 dto
자체를 넘겨서 생성자 안에서 get
을 하는 것이 좋나요??
컨벤션이나 가독성 측면에서 좋은 방법이 있는지 궁금합니다!
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.
@HubCreator
제가 알기로는 컨벤션으로 정해진 바는 없는 것으로 알고 있습니다.
제 경우 import
문을 줄이기 위해 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.
감사합니다!
private final String name; | ||
private int position = 0; |
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.
primitive
타입과 문자열 또한 객체로 감싸는 것은 어떨까요?
String name
을 객체로 만들면, 유효하지 못한 자동차 이름 검증을 해당 객체 생성자에서 validate
할 수 있을 것 같습니다.
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.
@HubCreator
말씀하신 바가 맞습니다! 왜 떠올리지 못했는지 모르겠네요.. 감사합니다!
@Override | ||
public int compareTo(Car target) { | ||
return target.position - this.position; | ||
} |
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.
Comparable을 구현한 것이 인상깊네요!
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.
Integer.compare(target.position, this.position)
으로 나타내는 방법도 있네요!
return gameStatusMappings.get(gameStatus).get(); | ||
} |
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.
@HubCreator
헉 그러네요 완전히 빠져버렸네요 ㄷㄷ 감사합니다! 시간날 때 리펙토링을 해야겠네요..
No description provided.