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

Step4 #4719

Open
wants to merge 15 commits into
base: prolkh
Choose a base branch
from
Open

Step4 #4719

wants to merge 15 commits into from

Conversation

prolkh
Copy link

@prolkh prolkh commented May 9, 2023

과제 목적에 맞게 구현했는지 의문이 들고있습니다.
그래도 일단 구현해보았습니다.
피드백 부탁드립니다.
감사합니다.

Copy link

@dave915 dave915 left a comment

Choose a reason for hiding this comment

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

경호님 안녕하세요! 4단계 구현하느라 고생하셨습니다 👍
몇가지 피드백 남겼습니다. 확인 부탁드릴게요.
피드백 반영하면서 궁금한점이나 어려운점 있으면 언제든지 DM부탁드릴게요!

@@ -6,14 +6,15 @@
public class Racing {
Copy link

Choose a reason for hiding this comment

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

Main 함수를 만들어서 프로그램이 실행 될 수 있게 만들어 주세요 :)

@@ -6,14 +6,15 @@
public class Racing {
private final List<Car> cars;
Copy link

Choose a reason for hiding this comment

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

Car 의 일급컬렉션을 만들어서 List<Car> cars 를 상태로 관리하게 해볼까요?

this.positions = new ArrayList<>(positions);
}

private void validateCarName(String name) {
if(name.length() > 5) {
Copy link

Choose a reason for hiding this comment

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

5 매직 넘버를 변수로 선언해서 해당 값이 어떤의미인지 설명해주세요!

https://javabom.tistory.com/28

Comment on lines 49 to 50
if(positions.isEmpty())
return -1;
Copy link

Choose a reason for hiding this comment

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

인텔리제이 자동정렬은 윈도우: Ctrl + Alt + L, macOS: Cmd + Alt + L 입니다 :)
코드 전체적으로 포맷팅이 필요 할 것 같아요!
그리고 if 문이 한줄이면 대괄호를 생략해도 되지만, 추후 수정할때 실수를 방지하기위해 대괄호를 쓰는건 어떠신가요?

Suggested change
if(positions.isEmpty())
return -1;
if (positions.isEmpty()) {
return -1;
}

private final List<Integer> positions;

Car(int trialCount) {
Car(String name, int trialCount) {
Copy link

Choose a reason for hiding this comment

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

이 생성자는 proceedOrStop 메소드가 항상 동일한 값을 리턴하지 않아서 테스트하기 어려울 것 같은데요.
어떻게 하면 테스트 할 수 있을까요?

@@ -50,14 +56,79 @@ public class RacingTest {
@Test
void 자동차_출력하기() {
Copy link

Choose a reason for hiding this comment

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

요구사항에 View 에 대한 테스트는 제외되어있어서 이 테스트는 안해도 될 것 같아요.
만약 하고싶으시다면 ResultView 테스트에 있어야 할 것 같습니다 :)


// Then
assertThat(inputView.getCarNames()).isEqualTo("pobi,crong,honux");
assertThat(inputView.getTrialCount()).isEqualTo(5);
}

@Test
void 랜덤하게_전진() {
Copy link

Choose a reason for hiding this comment

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

Car 들의 포지션 사이즈를 체크해보면 어떨까요?

@@ -28,18 +30,22 @@ public class RacingTest {
@Test
void 문자_입력_받기() {
Copy link

Choose a reason for hiding this comment

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

요구사항에 따르면 InputView에 관한 테스트는 생략해도 됩니다.
만약 하고싶으시다면, 해당 테스트는 InputViewTest 에 있어야 할 것 같네요.

Copy link

@dave915 dave915 left a comment

Choose a reason for hiding this comment

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

경호님 안녕하세요! 피드백 반영하면서 많은 수정이 있었네요 👍
몇가지 피드백 더 남겼습니다. 확인 부탁드릴게요!
궁금하거나 막히는 부분있으면 언제든 DM주세요.

public class Racing {
private final List<Car> cars;
// private final List<Car> cars;
private CarCollection carCollection;
Copy link

Choose a reason for hiding this comment

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

CarCollection 은 반드시 메인의 필드로 있어야 할까요?

List<Car> cars = new ArrayList<>();
for(int i=0; i<carCount; i++) {
cars.add(new Car(trialCount));
private void buildCarCollection(String carNames, int trialCount) {
Copy link

Choose a reason for hiding this comment

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

이 메소드는 CarCollection 내부로 이동 할 수 있지 않을까요?

import java.util.ArrayList;
import java.util.List;

public class CarCollection {
Copy link

Choose a reason for hiding this comment

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

CarCollection 은 List 타입을 설명하기 위한 객체명인데요!
레이싱참가자들 과 같은 객체명으로 어떤 객체인지 표현하는게 좋지 않을까요?

cars.add(car);
}

public void removeCar(Car car) {
Copy link

Choose a reason for hiding this comment

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

사용하지 않는 메소드는 삭제 해주세요 :)

return winner + "가 최종 우승했습니다.";
}

private int getBiggestLastPosition(CarCollection carCollection) {
Copy link

Choose a reason for hiding this comment

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

이 메소드는 우승자를 구할때 필요한 도메인 로직으로 보이는데요!
View 객체가 아닌 Domain 객체 내부로 이동해야 하지 않을까요?

객체의 레이어 구분을 위해 main/java/racingcar 패키지 하위로 view, domain을 패키지를 나눠주시고 각 객체들을 이동시켜보세요.

return max;
}

private String getWinner(CarCollection carCollection, int biggestLastPosition) {
Copy link

Choose a reason for hiding this comment

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

이 메소드도 도메인 객체로 이동해야하는 로직과 View에 남아있어야 할 로직이 섞여 있는 것 같아요 🥲

Comment on lines +18 to +22
assertThat(car.proceedOrStop()).isIn(0, 1);
assertThat(car.proceedOrStop()).isIn(0, 1);
assertThat(car.proceedOrStop()).isIn(0, 1);
assertThat(car.proceedOrStop()).isIn(0, 1);
assertThat(car.proceedOrStop()).isIn(0, 1);
Copy link

Choose a reason for hiding this comment

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

proceedOrStop 메소드는 내부에 랜덤값때문에 어떤 값이 나올지 몰라서 지금 같은 테스트 코드가 나온 것 같아요.
인터페이스를 이용해 랜덤숫자를 만드는 로직을 Car객체에서 분리해보세요 :)

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