-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Step5 PR요청드립니다. #6227
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
Step5 PR요청드립니다. #6227
Conversation
javajigi
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.
전체 코드를 삭제하고 다시 구현하는 것이 쉽지 않았을텐데요.
다시 구현하면서 새로운 인사이트를 느낀 점이 인상적이네요. 💯
확실히 기존에 비해 전체적인 설계가 개선된 것을 느낄 수 있네요.
추가로 "규칙 8: 일급 콜렉션을 쓴다." 원칙까지 적용하면서 마무리하면 좋을 것 같아 피드백 남겨 봅니다.
이제 자동차 경주 미션은 충분히 도전한 만큼 5단계는 시간 나는 짬짬히 도전해 보시고요.
로또 미션을 병행해 보면 어떨까요?
| this.value = value; | ||
| } | ||
|
|
||
| private void vaildation(String value) { |
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 vaildation(String value) { | |
| private void vaildate(String value) { |
명사보다는 동사로
| return "Position{" + | ||
| "value=" + value + | ||
| '}'; | ||
| public Position increase() { |
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.
불변 객체로 구현 👍
| import java.util.List; | ||
|
|
||
| public class RacingGame { | ||
| private List<RacingCar> racingCars; |
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.
한 단계 더 나아가 "규칙 8: 일급 콜렉션을 쓴다." 적용해 구현해 보면 어떨까?
| private List<RacingCar> racingCars; | ||
| private TryCount tryCount; |
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 List<RacingCar> racingCars; | |
| private TryCount tryCount; | |
| private final List<RacingCar> racingCars; | |
| private final TryCount tryCount; |
| if (racingCar.isGreaterThanPosition(maxPosition)) { | ||
| maxPosition = racingCar.getPosition(); | ||
| } |
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 (racingCar.isGreaterThanPosition(maxPosition)) { | |
| maxPosition = racingCar.getPosition(); | |
| } | |
| maxPosition = racingCar.max(maxPosition); |
객체의 값을 꺼내지 말고 메시지를 보낸다.
| public class TryCount { | ||
| private final int value; | ||
|
|
||
| public TryCount(int value) { |
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 (int i = 0; i < position.value(); i++) { | ||
| System.out.print("-"); | ||
| } |
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 (int i = 0; i < position.value(); i++) { | |
| System.out.print("-"); | |
| } | |
| "-".repeat(position.value()); |
- 명사 -> 동사(validation -> validate)
- Cars에 관련된 역할부여 - moveAll 테스트 -> NumberGenerator 생성
- TryCount는 값의 변동이 있어 처리 x
- 객체 접근 -> 메시지 - stream 적용
- 유효성 체크 추가 - 테스트코드 추가
- printPosition 반복문 repeat 적용
|
자동차경주 step5 리뷰요청 드립니다. 확인 부탁드립니다. |
javajigi
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.
그냥 무시할 수도 있을텐데 마지막에 자동차 경주 미션까지 마무리했네요. 👍
이 교육 과정이 준혁님이 한 단계 성장하는데 도움이 되었기를 바랍니다.
또 다른 기회를 통해 뵐 수 있기를 바랍니다.
step5 피드백 요청드립니다.
전부 지우고 다시 시작해보니, 접근이 조금 달라진거 같습니다.
결국은 비슷한 결과물이 나왔던거 같은데, 조금 더 하나의 객체에 역할을 부여하는 방향으로 접근해봤습니다.
다만, 마지막 RacingResult는 'MVC 패턴구조로 구현해본 샘플코드'를 보고 접근해봤습니다.
저는 RacingGame으로 끝냈던 상황이었는데, RacingResult를 보니 Game은 play의 역할에만, Result는 결과물에 대한 역할을 부여할 수 있을거 같아서 나누어 보았습니다.
아직 모든 원시값과 문자열을 포장하는데에 익숙하진 않은거 같은데, 아마 너무 절차지향적인 방법으로 많이 개발해와서 그런거 같습니다.
조금씩 적응하며 적용해보려고 합니다.
피드백 주시면 다시 한번 확인해보겠습니다.
감사합니다!