-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
base: prolkh
Are you sure you want to change the base?
Step4 #4719
Conversation
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.
경호님 안녕하세요! 4단계 구현하느라 고생하셨습니다 👍
몇가지 피드백 남겼습니다. 확인 부탁드릴게요.
피드백 반영하면서 궁금한점이나 어려운점 있으면 언제든지 DM부탁드릴게요!
@@ -6,14 +6,15 @@ | |||
public class Racing { |
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.
Main 함수를 만들어서 프로그램이 실행 될 수 있게 만들어 주세요 :)
src/main/java/racingcar/Racing.java
Outdated
@@ -6,14 +6,15 @@ | |||
public class Racing { | |||
private final List<Car> cars; |
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.
Car 의 일급컬렉션을 만들어서 List<Car> cars
를 상태로 관리하게 해볼까요?
src/main/java/racingcar/Car.java
Outdated
this.positions = new ArrayList<>(positions); | ||
} | ||
|
||
private void validateCarName(String name) { | ||
if(name.length() > 5) { |
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.
5
매직 넘버를 변수로 선언해서 해당 값이 어떤의미인지 설명해주세요!
src/main/java/racingcar/Car.java
Outdated
if(positions.isEmpty()) | ||
return -1; |
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.
인텔리제이 자동정렬은 윈도우: Ctrl + Alt + L
, macOS: Cmd + Alt + L
입니다 :)
코드 전체적으로 포맷팅이 필요 할 것 같아요!
그리고 if 문이 한줄이면 대괄호를 생략해도 되지만, 추후 수정할때 실수를 방지하기위해 대괄호를 쓰는건 어떠신가요?
if(positions.isEmpty()) | |
return -1; | |
if (positions.isEmpty()) { | |
return -1; | |
} |
private final List<Integer> positions; | ||
|
||
Car(int trialCount) { | ||
Car(String name, int trialCount) { |
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.
이 생성자는 proceedOrStop
메소드가 항상 동일한 값을 리턴하지 않아서 테스트하기 어려울 것 같은데요.
어떻게 하면 테스트 할 수 있을까요?
@@ -50,14 +56,79 @@ public class RacingTest { | |||
@Test | |||
void 자동차_출력하기() { |
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.
요구사항에 View 에 대한 테스트는 제외되어있어서 이 테스트는 안해도 될 것 같아요.
만약 하고싶으시다면 ResultView 테스트에 있어야 할 것 같습니다 :)
|
||
// Then | ||
assertThat(inputView.getCarNames()).isEqualTo("pobi,crong,honux"); | ||
assertThat(inputView.getTrialCount()).isEqualTo(5); | ||
} | ||
|
||
@Test | ||
void 랜덤하게_전진() { |
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.
Car 들의 포지션 사이즈를 체크해보면 어떨까요?
@@ -28,18 +30,22 @@ public class RacingTest { | |||
@Test | |||
void 문자_입력_받기() { |
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.
요구사항에 따르면 InputView에 관한 테스트는 생략해도 됩니다.
만약 하고싶으시다면, 해당 테스트는 InputViewTest 에 있어야 할 것 같네요.
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.
경호님 안녕하세요! 피드백 반영하면서 많은 수정이 있었네요 👍
몇가지 피드백 더 남겼습니다. 확인 부탁드릴게요!
궁금하거나 막히는 부분있으면 언제든 DM주세요.
public class Racing { | ||
private final List<Car> cars; | ||
// private final List<Car> cars; | ||
private CarCollection carCollection; |
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.
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) { |
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.
이 메소드는 CarCollection
내부로 이동 할 수 있지 않을까요?
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class CarCollection { |
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.
CarCollection
은 List 타입을 설명하기 위한 객체명인데요!
레이싱참가자들 과 같은 객체명으로 어떤 객체인지 표현하는게 좋지 않을까요?
cars.add(car); | ||
} | ||
|
||
public void removeCar(Car car) { |
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.
사용하지 않는 메소드는 삭제 해주세요 :)
return winner + "가 최종 우승했습니다."; | ||
} | ||
|
||
private int getBiggestLastPosition(CarCollection carCollection) { |
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.
이 메소드는 우승자를 구할때 필요한 도메인 로직으로 보이는데요!
View 객체가 아닌 Domain 객체 내부로 이동해야 하지 않을까요?
객체의 레이어 구분을 위해 main/java/racingcar 패키지 하위로 view, domain을 패키지를 나눠주시고 각 객체들을 이동시켜보세요.
return max; | ||
} | ||
|
||
private String getWinner(CarCollection carCollection, int biggestLastPosition) { |
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.
이 메소드도 도메인 객체로 이동해야하는 로직과 View에 남아있어야 할 로직이 섞여 있는 것 같아요 🥲
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); |
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.
proceedOrStop
메소드는 내부에 랜덤값때문에 어떤 값이 나올지 몰라서 지금 같은 테스트 코드가 나온 것 같아요.
인터페이스를 이용해 랜덤숫자를 만드는 로직을 Car객체에서 분리해보세요 :)
과제 목적에 맞게 구현했는지 의문이 들고있습니다.
그래도 일단 구현해보았습니다.
피드백 부탁드립니다.
감사합니다.