-
Notifications
You must be signed in to change notification settings - Fork 132
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
[Spring Core] 이가연 미션 제출합니다. #380
base: gy102912
Are you sure you want to change the base?
Conversation
GY102912
commented
Nov 15, 2024
- ExceptionHandling은 컨트롤러, 서비스, 리포지토리 중 어디에서 이루어져야 할까요?
- 엔티티와 필드가 완전히 동일하더라도 DTO를 따로 만드는 것이 좋을까요?
- request body, response body 각각 포함하는 필드가 서로 다를 때 RequestDTO, ResponseDTO를 분리하는 것 말고 다른 좋은 방법은 없을까요? 엔티티가 많은 경우 DTO가 너무 많아져서 복잡할 것 같습니다.
- 넘기는 매개변수가 적다면 따로 DTO를 만들지 않아도 괜찮을까요?
- 컨트롤러, 서비스, 리포지토리 각각의 메소드 명명 규칙이 따로 있는지 궁금합니다.
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 final ReservationService reservationService; | ||
|
||
@Autowired |
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.
@Autowired를 붙인것과 안 붙인거는 어떤 차이가 있나요?
return ResponseEntity.noContent().build(); | ||
} | ||
|
||
@ExceptionHandler({NoSuchElementException.class, MethodArgumentNotValidException.class}) |
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.
에러 핸들링을 위해 ExceptionHandler를 추가하셨군요.
이 메서드를 controller에 추가하신 이유는 어떤건가요?
@Controller | ||
public class TimeController { | ||
|
||
TimeService timeService; |
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.
접근 제어자를 package-private로 두신 이유가 있으실까요??
|
||
private String time; | ||
|
||
public static Time create(Long id, String time) { |
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.
정적 팩터리 메서드가 일반적인 생성자와 동일하게 동작하는 것 같아요 별도로 정적 팩터리 메서드를 추가하신 이유가 있으신가요?
@Repository | ||
public class ReservationRepository { | ||
|
||
@Autowired |
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.
필드 주입으로 jdbcTemplate을 주입해주셨군요.
주입 방법엔 여러가지가 있는데, 필드 주입을 사용하시는 이유가 있으신가요?
@Autowired | ||
JdbcTemplate jdbcTemplate; | ||
|
||
private final RowMapper<Reservation> rowMapper = (resultSet, rowNum) -> |
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.
rowMapper를 깔끔하게 분리해주신 게 좋네요!
import roomescape.entity.Time; | ||
|
||
@Repository | ||
public class TimeRepository { |
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.
이름을 Repository라고 지어주셨군요.
Repository와 Dao는 어떤 차이가 있을까요?