-
Notifications
You must be signed in to change notification settings - Fork 11
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
[민섭] racingGame Step2 구현완료 했습니다. #33
base: econo-minseop
Are you sure you want to change the base?
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.
일단 큰 리뷰들만 남겼습니다 반영해주세요.
tempWinnerPosition = car.getCarPosition(); | ||
} | ||
return tempWinnerPosition; | ||
} |
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 클래스가 요구사항이 추가될수록 점점 무거워진다는 느낌이 들지 않나요?
이 중에서 공통으로 묶을 수 있는 역할들을 추상화 시켜서 새로운 클래스를 만들어보고, 그 클래스로 행위들을 위임시켜보세요
private String splitPlayersName(String players, int index) { | ||
String[] names = players.split(","); | ||
return names[index]; | ||
} |
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 이 책임을 갖고 있기 보다는 새 클래스를 만들어서 위임시켜도 될 것 같습니다. 제가 보기엔 그냥 String 관련 작업같아보여서요.
|
||
public void settingCar(int numCar) { | ||
|
||
public void settingCar(String players) { |
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에서 players를 넘겨줄 때 분리시킨 결과(배열 or List)를 넘기면 RacingGame에 아래와 같은 슬데없이 복잡한 로직이 생기지 않아도 될 것 같습니다
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 playerName; | ||
} | ||
|
||
public String inputPlayerName(String name) { |
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.
setPlayerName이 아닐까요. input은 View에서 받아오는 것처럼 읽힙니다
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.
그러므로 결국 set을 사용하셨네요
public class Main { | ||
public static void main(String[] args) { | ||
RacingGame racingGame = new RacingGame(); | ||
Winner winner = new Winner(); |
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.
의미상 WinnerGenerator 혹은 WinnerMaker가 어울려보입니다
Car car = new Car(); | ||
cars.add(car); | ||
cars.get(i).inputPlayerName(splitPlayersName(players, i)); | ||
cars.get(i).inputPlayerName(names[i]); |
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.
메소드 이름이 Input 이니까 뭔가 입력을 받아야할 것 같습니다. 근데 역할로 보면 세터같은데 setPlayerName이 아닐까요?
|
||
public class Winner { | ||
private List<Car> winnerList; | ||
private static int winnerPosition; |
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.
왜 static이죠?
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에서 MOVE_RESTRICTION을 static으로 선언한거 보고 의미 파악도 안한테 무의식 중에 그런것 같습니다. static이란 모든 객체가 공유할만한 변수에 필요한건데 혁진님의 말대로 winnerPosition은 각자 다른 값을 갖는 변수임으로 static으로 선언한것은 잘 못 한것 같습니다.
|
||
public List<Car> makeWinners(List<Car> cars) { | ||
calculateWinnerPosition(cars); | ||
winnerList = new ArrayList<>(); |
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 void checkWinnerName(Car car) { | ||
if (car.getCarPosition() == winnerPosition) { | ||
winnerList.add(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.
check 라고 이름 지어놓고 add를 하고 있네요
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.
메소드 이름이 곧 그 메소드의 역할과 행위를 나타내므로 매우 중요합니다. 메소드 이름을 잘 짓느냐 안 짓느냐에 따라서 그 메소드를 분리해야하느냐 마느냐가 결정되기도 합니다
private void calculateWinnerPosition(List<Car> cars) { | ||
int tempWinnerPosition = 0; | ||
for (Car car : cars) { | ||
tempWinnerPosition = checkWinnerPosition(tempWinnerPosition, 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.
temp를 왜 만든건지 모르겠습니다
winnerPosition = tempWinnerPosition; | ||
} | ||
|
||
private int checkWinnerPosition(int tempWinnerPosition, 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.
위너의 포지션값을 체크한다는 뜻인 것 같은데 실제 동작하는건 비교해서 결과를 반환해주는 것 같네요.
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.
이름을 다르게 수정했습니다.
|
||
private int checkWinnerPosition(int tempWinnerPosition, Car car) { | ||
if (car.getCarPosition() > tempWinnerPosition) { | ||
tempWinnerPosition = car.getCarPosition(); |
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.
get을 사용하셨네요
리뷰 부탁드립니다.