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
[2단계 - 웹 자동차 경주] 제이(이재윤) 미션 제출합니다. #103
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.
안녕하세요 제이!
1단계때보다 계층간 경계가 뚜렷해진 코드가 됐네요 👍🏻
미션 잘 구현해주셨습니다! 몇가지 코멘트 남겼는데 확인해주세요.
src/main/java/racingcar/controller/RacingGameWebController.java
Outdated
Show resolved
Hide resolved
src/main/java/racingcar/controller/RacingGameConsoleController.java
Outdated
Show resolved
Hide resolved
src/test/java/racingcar/controller/RacingGameWebControllerTest.java
Outdated
Show resolved
Hide resolved
src/main/java/racingcar/controller/RacingGameWebController.java
Outdated
Show resolved
Hide resolved
src/main/java/racingcar/controller/RacingGameWebController.java
Outdated
Show resolved
Hide resolved
src/main/java/racingcar/controller/RacingGameWebController.java
Outdated
Show resolved
Hide resolved
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.
피드백 잘 반영해주셨네요 제이! 많은 고민이 느껴져서 좋았습니다 👍🏻
코멘트 답변과 리뷰를 추가했는데 한번 더 확인해주세요.
@NotBlank(message = "이름을 입력해주세요.") | ||
private String names; | ||
|
||
@NotNull(message = "시도 회수를 입력해주세요.") | ||
@Min(value = 2, message = "최소 횟수는 2입니다.") | ||
@Max(value = 10, message = "최대 횟수는 10입니다.") |
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.
@Valid
를 사용해주셨네요! 어떤 장단점이 있었나요?
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.
- 제가 생각한
@Valid
의 장점은 다음과 같습니다.
- 사용자의 입력에 대한 데이터 유효성을 검사할 수 있습니다. (DB에 잘못된 데이터가 들어갈 확률이 낮아집니다!)
- 사용하다보니 규모가 커질 경우 예외를 검증하는 코드를 따로 작성하지 않아도 돼서 생산성에 있어서 좋다고 생각합니다.
- 제가 생각한 단점은 다음과 같습니다.
- 어노테이션 사용법을 알아야하기 때문에, 모르는 팀원이 있으면 오히려 시간이 더 걸릴 수 있습니다.
- 또한 직접 사용하다 보니 어떤 예외를 던지는지에 대해 공부를 따로 했습니다. 제가 아직은 자세히 모르는 것일 수도 있겠지만, 커스텀 예외를 따로 만들어서 발생시키기 힘든 것 같습니다.
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.
좋네요 👍🏻 여기서 조금 더 보완해드리자면,
사용하다보니 규모가 커질 경우 예외를 검증하는 코드를 따로 작성하지 않아도 돼서 생산성에 있어서 좋다고 생각합니다.
편리한 점이 있어도 웹 요청에 한정해서 비교적 간단한 검증만 이루어져야하고, 핵심 도메인에 대한 검증까지 이를 대체하려고 하면 안됩니다. 복잡한 도메인 로직을 타기 전에 간단한 검증을 도와주는 장치이지 비즈니스 로직을 대체하는 장치가 아니라는 점이 중요합니다 🙂
커스텀 예외를 따로 만들어서 발생시키기 힘든 것 같습니다.
이는 좋게 작용할 여지도 있다고 생각해요. 잘못된 요청에 대해선 일괄로 가벼운 처리와 4xx 응답 코드를 던져주는처리를 할 수 있고, 또 커스텀 예외가 필요하다면 MethodArgumentNotValidException
을 상속받는 커스텀 예외를 만들어서 처리할 수도 있을 것 같네요!
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 주세요.
터틀, 안녕하세요!
이번 미션을 구현하면서, Service와 DAO 레이어의 역할을 분리할 수 있도록 노력했습니다.
Service 레이어는 비즈니스 로직을 처리할 수 있는 것의 초점을 맞췄고,
DAO 레이어는 조회, 저장 같은 데이터베이스에 접근할 수 있는 것의 초점을 맞췄습니다.
그리고 웹 컨트롤러에서 중복된 URI를 없애기 위해서
@RequestMapping()
을 사용했습니다.또한 테스트 같은 경우 Controller는 요청에 초점을 맞추고, Service는 비즈니스 로직을 제대로 수행하는지에 초점을 맞추고 진행하였습니다.
이번에도 잘 부탁 드립니다!
감사합니다 :)