Skip to content

Conversation

@hyunhyun
Copy link

@hyunhyun hyunhyun commented Jul 7, 2022

안녕하세요 step2 경로 조회 기능 리뷰 요청드립니다~ 감사합니다.

Copy link

@chae-yh chae-yh left a comment

Choose a reason for hiding this comment

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

정현님 안녕하세요! step1의 피드백 잘 반영해주셨고, step2의 코드도 전체적으로 잘 작성해주셨습니다 👍
다만 조금 더 고민해주시면 좋을만한 내용이 있어 코멘트 드리니 확인 부탁드립니다!

감사합니다 : )

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
Copy link

Choose a reason for hiding this comment

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

@RestControllerAdvice 를 사용하여 모든 에러를 한군데서 처리해줄 수 있게해준 부분 좋습니다 👍

@RestControllerAdvice
public class ControllerExceptionHandler {

@ExceptionHandler(DataIntegrityViolationException.class)
Copy link

Choose a reason for hiding this comment

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

이 부분은 조금 궁금하여 여쭤봅니다! DataIntegrityViolationException 는 현재 어플리케이션 내에서 언제, 어떤 케이스에서 발생하게 되나요...?


public class Lines {

List<Line> lines = new ArrayList<>();
Copy link

Choose a reason for hiding this comment

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

접근제한자가 없는 것 같습니다!

this.lines = lines;
}

public GraphPath minPath(Station sourceStation, Station targetStation) {
Copy link

Choose a reason for hiding this comment

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

동사구로 메서드를 표현해보는 것은 어떨까요...? 그리고 혹시 제너릭을 안쓰시는 이유가 있으실까요...?

private boolean stationExistsAtEnd(Section section) {
return sections.stream().anyMatch(
sectionIterate -> sectionIterate.getDownStation().equals(section.getUpStation())
|| sectionIterate.getUpStation().equals(section.getDownStation()));
Copy link

Choose a reason for hiding this comment

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

이부분도 Section에 메시지를 던져서 확인해볼 수 있을 것 같습니다


private void connectFrontBackSection(Line line, Optional<Section> upLineStation, Optional<Section> downLineStation) {
private void connectFrontBackSection(Line line, Optional<Section> upLineStation,
Optional<Section> downLineStation) {
Copy link

Choose a reason for hiding this comment

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

여기까지 피드백 반영 좋네요 ㅎㅎ 👍

}

public PathResponse minPath(Long sourceStationId, Long targetStationId) {
System.out.println("PathService.minPath");
Copy link

Choose a reason for hiding this comment

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

여기에 혹시 System 함수를 쓰신 이유가 있을까요...? Sysytem 함수는 리소스를 많이 먹어서 최대한 사용하지 않는 것이 좋습니다.

public PathResponse minPath(Long sourceStationId, Long targetStationId) {
System.out.println("PathService.minPath");

Station sourceStation = stationRepository.findById(sourceStationId)
Copy link

Choose a reason for hiding this comment

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

Repository 조회하는 부분이 있는데 readOnly 옵션을 주는 것은 어떨까요....?



@DisplayName("지하철 경로 조회")
public class PathAcceptanceTest extends AcceptanceTest {
Copy link

Choose a reason for hiding this comment

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

인수테스트 좋습니다 👍 다만 이번에 새로만드신 Lines에 대한 단위 테스트, PathService에 대한 단위테스트도 추가되면 좋을 것 같습니다!
Lines의 경우 실제 외부 라이브러리를 사용하므로 해당 실제 객체를 이용하여 테스트를 작성하고, PathService의 경우는 외부 의존성을 Mocking 한 단위 테스트를 작성해보는 것도 좋은 공부가 될 것 같습니다!


@Test
@DisplayName("경로 조회시 미존재 역 에러 확인")
public void findMinPathNotExsistStation() {
Copy link

Choose a reason for hiding this comment

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

연결되어 있지 않은 역에 대한 최단거리 조회의 경우에도 테스트를 추가해보는 것은 어떨까요...?

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