[Spring Core] 이가연 미션 제출합니다.#380
Open
GY102912 wants to merge 10 commits into
Open
Conversation
GY102912
commented
Nov 15, 2024
- ExceptionHandling은 컨트롤러, 서비스, 리포지토리 중 어디에서 이루어져야 할까요?
- 엔티티와 필드가 완전히 동일하더라도 DTO를 따로 만드는 것이 좋을까요?
- request body, response body 각각 포함하는 필드가 서로 다를 때 RequestDTO, ResponseDTO를 분리하는 것 말고 다른 좋은 방법은 없을까요? 엔티티가 많은 경우 DTO가 너무 많아져서 복잡할 것 같습니다.
- 넘기는 매개변수가 적다면 따로 DTO를 만들지 않아도 괜찮을까요?
- 컨트롤러, 서비스, 리포지토리 각각의 메소드 명명 규칙이 따로 있는지 궁금합니다.
hong-sile
reviewed
Nov 16, 2024
hong-sile
left a comment
There was a problem hiding this comment.
전체적으로 수고많으셨습니다!!
몇몇 부분에 대해서 코멘트 남겼으니 확인부탁드려요.
늘 이야기하듯 제가 정답이 아니기 때문에 질문 반박 토론 언제든 환영입니다.
|
|
||
| private final ReservationService reservationService; | ||
|
|
||
| @Autowired |
| return ResponseEntity.noContent().build(); | ||
| } | ||
|
|
||
| @ExceptionHandler({NoSuchElementException.class, MethodArgumentNotValidException.class}) |
There was a problem hiding this comment.
에러 핸들링을 위해 ExceptionHandler를 추가하셨군요.
이 메서드를 controller에 추가하신 이유는 어떤건가요?
| @Controller | ||
| public class TimeController { | ||
|
|
||
| TimeService timeService; |
There was a problem hiding this comment.
접근 제어자를 package-private로 두신 이유가 있으실까요??
|
|
||
| private String time; | ||
|
|
||
| public static Time create(Long id, String time) { |
There was a problem hiding this comment.
정적 팩터리 메서드가 일반적인 생성자와 동일하게 동작하는 것 같아요 별도로 정적 팩터리 메서드를 추가하신 이유가 있으신가요?
| @Repository | ||
| public class ReservationRepository { | ||
|
|
||
| @Autowired |
There was a problem hiding this comment.
필드 주입으로 jdbcTemplate을 주입해주셨군요.
주입 방법엔 여러가지가 있는데, 필드 주입을 사용하시는 이유가 있으신가요?
| @Autowired | ||
| JdbcTemplate jdbcTemplate; | ||
|
|
||
| private final RowMapper<Reservation> rowMapper = (resultSet, rowNum) -> |
| import roomescape.entity.Time; | ||
|
|
||
| @Repository | ||
| public class TimeRepository { |
There was a problem hiding this comment.
이름을 Repository라고 지어주셨군요.
Repository와 Dao는 어떤 차이가 있을까요?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.