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

[자동차 경주 게임] 김지민 미션 제출합니다. #1

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

Conversation

apptie
Copy link
Owner

@apptie apptie commented Dec 11, 2022

No description provided.

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);

Choose a reason for hiding this comment

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

RacingGame 생성자의 인자에 dto에서 값을 꺼내서 전해주는 것이 좋나요? 아니면 dto 자체를 넘겨서 생성자 안에서 get을 하는 것이 좋나요??

컨벤션이나 가독성 측면에서 좋은 방법이 있는지 궁금합니다!

Copy link
Owner Author

Choose a reason for hiding this comment

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

@HubCreator
제가 알기로는 컨벤션으로 정해진 바는 없는 것으로 알고 있습니다.

제 경우 import문을 줄이기 위해 dto에서 값을 꺼내서 전달해주는 것을 선호하는 편입니다!

Choose a reason for hiding this comment

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

감사합니다!

Comment on lines +15 to +16
private final String name;
private int position = 0;

Choose a reason for hiding this comment

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

primitive 타입과 문자열 또한 객체로 감싸는 것은 어떨까요?

String name을 객체로 만들면, 유효하지 못한 자동차 이름 검증을 해당 객체 생성자에서 validate할 수 있을 것 같습니다.

Copy link
Owner Author

Choose a reason for hiding this comment

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

@HubCreator
말씀하신 바가 맞습니다! 왜 떠올리지 못했는지 모르겠네요.. 감사합니다!

Comment on lines +35 to +38
@Override
public int compareTo(Car target) {
return target.position - this.position;
}

Choose a reason for hiding this comment

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

Comparable을 구현한 것이 인상깊네요!

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)으로 나타내는 방법도 있네요!

Comment on lines +35 to +36
return gameStatusMappings.get(gameStatus).get();
}

Choose a reason for hiding this comment

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

사용자 입력에 대한 예외 처리 부분이 빠진 것 같습니다!

Copy link
Owner Author

Choose a reason for hiding this comment

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

@HubCreator
헉 그러네요 완전히 빠져버렸네요 ㄷㄷ 감사합니다! 시간날 때 리펙토링을 해야겠네요..

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.

2 participants