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

4단계 - 자동차 경주(우승자) #5104

Open
wants to merge 4 commits into
base: hypernova1
Choose a base branch
from

Conversation

hypernova1
Copy link

4단계 제출합니다.

Copy link

@bingbingpa bingbingpa left a comment

Choose a reason for hiding this comment

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

4단계 미션 잘 구현해주셨네요! 👍
근데 테스트와 관련해서 조금 아쉬운 부분들이 있어서 리뷰 남겨드렸어요.
한 번 확인해보시고 다시 한번 리뷰 요청 부탁드려요.

Comment on lines +11 to +16



List<Car> cars = new ArrayList<>(names.length);
for (String name : names) {
validateName(name);

Choose a reason for hiding this comment

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

불필요한 공백과 validateName 이 구현되지 않았네요.

Comment on lines +10 to +11
private ResultView() {
}

Choose a reason for hiding this comment

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

인스턴스가 없고, static method 만 있는 클래스들에 동일하게 적용해보는건 어떨까요?
InputView 는 인스턴스를 생성하고, ResultView 는 인스턴스 생성 없이 쓰고 있네요.
CarFactory 또한 일종의 팩토리 메소드 같은데요. createCars 를 통해 생성하도록 기본 생성자는 사용못하도록 하는건 어떨까요?

}

public List<Car> start() {
System.out.println("실행 결과");

Choose a reason for hiding this comment

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

이 출력도 ResultView 에서 수행하는건 어떨까요?


private void validateName(String name) {
if (name.length() > MAX_NAME_SIZE) {
throw new RuntimeException();

Choose a reason for hiding this comment

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

RuntimeException 보다는 조금 더 명확한 익셉션이나 커스텀한 익셉션을 만들어 사용하는건 어떨까요?
그리고 왜 에러가 발생했는지 메시지를 조금 더 명확하게 주면 좋을 것 같아요.


@DisplayName("자동차의 이름은 5자를 초과할 수 없다")
@Test
void test2() {

Choose a reason for hiding this comment

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

테스트 메소드명을 조금 더 명확히 하는건 어떨까요?


@DisplayName("우승자를 선정한다 우승자는 1명 이상이다.")
@Test
void test3() {

Choose a reason for hiding this comment

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

테스트의 검증이 조금 모호한 것 같아요.
실제 racing 을 의도한 대로 수행하고 예측한 자동차가 우승자로 선정되는지를 판별하는건 어떨까요?

@@ -0,0 +1,48 @@
package step4.domain;

public class Car {

Choose a reason for hiding this comment

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

Car 에 대한 테스트도 작성해보면 어떨까요?


public class NumberUtil {
public static int createRandomNumber() {
return (int) (Math.random() * 10);

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.

2 participants