-
Notifications
You must be signed in to change notification settings - Fork 263
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
[지하철 경로조회] 코드리뷰 #117
base: main
Are you sure you want to change the base?
[지하철 경로조회] 코드리뷰 #117
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.
저도 application에서는 controller만 받게끔 만들어 봐야 겠어요!!
} | ||
|
||
public static String inputKey(List<String> candidateKeys){ | ||
System.out.println(InputMessage.SELECT_WANTED.getValue()); |
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.
이 부분도 OutputView로 옮기면 어떨까요?
} | ||
|
||
public void initStation(){ | ||
stationService.initStation(); |
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.
계층 구조를 잘 지키셨군요! 👍
public class GraphService { | ||
private final GraphRepository graphRepository = GraphRepository.getInstance(); | ||
private final StationRepository stationRepository = StationRepository.getInstance(); | ||
private static final int ZERO = 0; |
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.
기본형 숫자인 경우 지금처럼 클래스마다 관리하는 것
vs enum으로 정리해서 관리하는 것
어떤 방법이 더 좋다고 생각해요??
Station startStation = stationRepository.findByName(startStationInfo); | ||
Station endStation = stationRepository.findByName(endStationInfo); | ||
if(startStation.isEqualName(endStationInfo)){ | ||
throw new SameStationException(SAME_AS.getValue()); |
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.
메서드에서 예외를 throw 해버리면 프로그램이 비정상적으로 종료되어버리죠. 그렇게 하지 않기 위해 보통 try-catch를 감싸는데 지금처럼 검증을 하고 예외를 발생하는 경우에도 try-catch 때문에 코드가 지저분해지더라도 작성하는게 옳다고 생각하시나요?
어떤 방법이 좋을까요..?
} | ||
|
||
public void initSubway(){ | ||
subwayService.initSubway(); | ||
} | ||
|
||
public void start(){ | ||
try{ | ||
if(questionIsproceed()){ | ||
while(questionIsproceed()){ |
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.
낙타표기법에 의해 questionIsProceed()
라고 작명하면 좋겠군요!
} | ||
|
||
private List<Integer> getShortestTime(){ | ||
String startStationInfo = InputView.inputStation(InputMessage.GET_START_STATION.getValue()); |
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.
getShorestDistance()
메서드와 내용이 중복되군요. startStationInfo, endStationInfo를 만드는 부분을 메서드로 만들면 어떨까요?
return graphService.getTotalShortestDistanceAndShortestTime(path); | ||
} | ||
|
||
private void savetotalInfo(final List<Integer> totalInfo){ |
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.
여기도 낙타표기법으로 saveTotalInfo()
가 좋을거 같아요!
@@ -5,13 +5,15 @@ | |||
import static subway.util.message.ExceptionMessage.INPUT_MESSAGE; | |||
|
|||
public class StationValidator extends Validator{ |
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.
이 부분에서 Validator를 상속해주는 것은 큰 상관 없을것 같아요! isBlank()
메서드는 공통 로직이니까요~
하지만 Validator 해야 할 클래스가 100개 있다고 가정해볼게요. 그럼 그만큼 공통 검증 사항을 뽑기는 쉽지 않을거예요...
그럴 때는 extends 대신 implements으로 구현해보는 것도 방법이 될 것 같아요!!
No description provided.