-
Notifications
You must be signed in to change notification settings - Fork 55
[조재민_BackEnd] 과제 제출합니다. #58
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
base: main
Are you sure you want to change the base?
Conversation
|
수고하셨습니다!! 👍
|
| final int MOVE_NUMBER = 4; | ||
| final int START_NUMBER = 0; | ||
| final int END_NUMBER = 9; |
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.
상수 처리 잘 해주셨습니다 👍
| if (carName.length() > MAX_NAME) { | ||
| throw new IllegalArgumentException("[ERROR] 이름은 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.
for 문 안에 있는 조건문을 함수로 만들어 Depth를 줄이면 좋을 것 같습니다 👍
|
|
||
| String winnerString = String.join(", ", winners); | ||
| System.out.println("최종 우승자 : " + winnerString); | ||
| } |
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.
위와 마찬가지로 최대한 코드 Depth를 줄여보시면 좋을 것 같아요!
|
리펙토링으로 Depth 부분을 줄이고 책임을 분리하였습니다. 혹여나 더 나눌 수 있다면 말씀 부탁드립니다. |
asa9874
left a comment
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 클래스의 사용에 대한 생각을 몇개 남겼습니다.
| Car car = new Car(); | ||
| String[] carNames = car.getCarNames(); | ||
| int rounds = car.getRounds(); | ||
|
|
||
| Racing racing = new Racing(carNames, rounds); |
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 클래스가 지금은 코드의 비즈니스 로직이 진행되는 Racing 클래스내부에서 활용되지않고 입력받는용도로 활용되고있는거같아요.
Car 객체 리스트 대신 String[] carNames로 사용되고있는데, Car 객체를 활용해서 해보는건 어떨까요?
| private final String[] carNames; | ||
| private final int rounds; | ||
| private final int[] positions; |
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.
carNames, positions 를 Racing에서 따로 String[]으로 선언하지않고
각각 하나의 Car 객체를 만들어서 List을 통해 사용하는게 객체지향적일거같아요.
이렇게 하면 이름과 위치가 한 객체 안에서 함께 관리되기 때문에 데이터 일관성 유지 (인덱스 잘못 맞출 위험)면에서 좋을거같아요
| } | ||
| } | ||
|
|
||
| public int getRounds() { |
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.
Round는 Car 객체내부에서 사용되는 정보라기보다는 Racing 에서 사용되는 변수인거같아요. 이부분에 대해서는 생각해보시면 좋을거같습니다.
| winners.add(carName); | ||
| } | ||
| } | ||
| } No newline at end of file |
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.
EOF 에 대해 한번 알아보시면 좋을거같습니다.
일단 메인 외에 Car와 Racing을 추가했는데 혹시 더 세분화할 수 있는게 있으면 추천 부탁드립니다.