Skip to content

Conversation

@nonactress
Copy link

@nonactress nonactress commented Nov 6, 2025

안녕하세요! 혜빈님 처음 리뷰 받게 되었습니다. 잘 부탁드립니다!!

AdminController 클래스
home : 웹사이트의 메인 페이지(/)로 접속하면(GET), home.html 템플릿 파일을 찾아 렌더링하여 반환하라는 코드입니다.
reservation : reservation.html 페이지를 보여주는 컨트롤러와, 임의의 예약 목록(JSON)을 반환하는 API 컨트롤러를 각각 구현한 코드입니다.

ReservationController 클래스: 서버 시작 시 '브라운'과 '코니'라는 임시 예약 2건을 미리 생성해두고, GET /reservations API 요청이 오면 이 목록 전체를 JSON으로 반환하는 코드입니다.

궁금한 점

  1. 현재 테스트 코드 2단계 is메소드가 import 되지 않았다고 하는데 어떤 패키지를 가져와서 써야 하는지 잘 모르겠습니다!

@c0mpuTurtle
Copy link

c0mpuTurtle commented Nov 10, 2025

🌱<인사>

안녕하세요, 현진님 🙂
만나뵙게 되어 영광입니다 :)
제 의견을 무조건적으로 수용하실 필요는 없으니, 현진님의 의견을 과감없이 말씀해주셨으면 좋겠어요.
같이 티키타카 해봅시다! 화이팅!

❓<질문에 대한 답>

(현진) 테스트 코드 2단계 is메소드의 의존성을 못 찾겠어요.

->
is() 메서드는 Hamcrest 라이브러리에서 제공되는 매처입니다.
테스트 코드 상단에 아래 import 문을 추가하면 정상적으로 사용할 수 있어요.

import static org.hamcrest.Matchers.is;

보통 assertThat() 메서드와 함께 사용되며,
예를 들어 assertThat(actual, is(expected)); 형태로 기대값을 검증할 때 활용됩니다.!!

Comment on lines +1 to +29
package roomescape.model;

public class Reservation {

private String name;
private String date;
private String time;

public Reservation() {
}

public Reservation(String name, String date, String time) {
this.name = name;
this.date = date;
this.time = time;
}

public String getName() {
return name;
}

public String getDate() {
return date;
}

public String getTime() {
return time;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DTO를 도입해서 도메인 객체(Reservation)와 API 요청/응답 데이터를 분리하는 게 어떨까요?

아직은 예약 조회 기능만 있어서 사실 record를 사용하라고 조언해드리고 싶습니다.
하지만 이후에 예약 수정이나 삭제 기능이 추가될 예정이라면 record 형태의 DTO와 도메인 객체를 함께 두는 게 나을 거 같네요.

현재처럼 Reservation을 엔티티로 두면 해당 객체가 그대로 외부에 노출되기 때문에, 데이터 보안 측면에서 위험할 거 같아요.

Comment on lines +9 to +10
public Reservation() {
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

현재 쓰이고 있지 않는 생성자인 거 같은 데 왜 넣어두셨는 지 여쭤봐도 될까요?

Comment on lines +18 to +28
public String getName() {
return name;
}

public String getDate() {
return date;
}

public String getTime() {
return time;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

객체를 만들면서 습관적으로 getter도 함께 추가하신 게 아닐까 추측해봅니다.
개인적으로는 사용하지 않는 메서드는 제거하는 편이 더 좋다고 생각해요.

@RestController
@RequestMapping("/reservations")
public class ReservationController {
private final List<Reservation> reservations = new ArrayList<>();
Copy link

@c0mpuTurtle c0mpuTurtle Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이렇게 현재 ReservationController 내부에서 List를 직접 관리했을 때 생길 수 있는 문제는 어떤 것들이 있을까요?
키워드 : 동시성 문제, 데이터 영속성

(아직 데이터베이스가 없기도 하고, 예약 데이터 관리 예시 코드가 이렇게 주어져서 이렇게 코드 짜신 거 알고 있습니다.)

Comment on lines +14 to +18
@GetMapping("/reservation")
public String reservation()
{
return "reservation";
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image 사진을 참고하여 이 부분의 Spring MVC 동작과정을 설명해볼까요? 분명히 도움이 될거예요 :)

Comment on lines +11 to +23
public class ReservationController {
private final List<Reservation> reservations = new ArrayList<>();

public ReservationController() {
reservations.add(new Reservation( "브라운", "2025-01-01", "10:00"));
reservations.add(new Reservation("코니", "2025-01-02", "11:00"));
}

@GetMapping
public List<Reservation> getAllReservations() {
return reservations;
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReservationController가 직접 데이터를 관리하고 있네요.
지금 당장은 단순해서 필요없긴 한데, 데이터를 다루는 부분은 Service 레이어로 분리해두면 이후 기능 확장이나 DB 연동 시 훨씬 유연하게 유지보수할 수 있을 거예요.

기능이 얼마 없을 때, 미리 한 번 나누어 볼까요?

@c0mpuTurtle
Copy link

c0mpuTurtle commented Nov 10, 2025

미션 정말 잘 진행해주셨네요 🙂
수고 많으셨습니다! 이번 1차 코멘트는 여기까지 마무리할게요.
확인하신 뒤 댓글 남기시고 멘션 걸어주세요 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants