Conversation
|
지하철 노선도 경로 조회 미션이 다른 문제보다 까다로웠는데 계층 구조도 지키고 새로운 방법도 시도해보고... 대단하십니다!! 👍 |
There was a problem hiding this comment.
저도 application에서는 controller만 받게끔 만들어 봐야 겠어요!!
| } | ||
|
|
||
| public static String inputKey(List<String> candidateKeys){ | ||
| System.out.println(InputMessage.SELECT_WANTED.getValue()); |
| } | ||
|
|
||
| public void initStation(){ | ||
| stationService.initStation(); |
| 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.
기본형 숫자인 경우 지금처럼 클래스마다 관리하는 것 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.
메서드에서 예외를 throw 해버리면 프로그램이 비정상적으로 종료되어버리죠. 그렇게 하지 않기 위해 보통 try-catch를 감싸는데 지금처럼 검증을 하고 예외를 발생하는 경우에도 try-catch 때문에 코드가 지저분해지더라도 작성하는게 옳다고 생각하시나요?
어떤 방법이 좋을까요..?
| public void start(){ | ||
| try{ | ||
| if(questionIsproceed()){ | ||
| while(questionIsproceed()){ |
There was a problem hiding this comment.
낙타표기법에 의해 questionIsProceed() 라고 작명하면 좋겠군요!
| } | ||
|
|
||
| private List<Integer> getShortestTime(){ | ||
| String startStationInfo = InputView.inputStation(InputMessage.GET_START_STATION.getValue()); |
There was a problem hiding this comment.
getShorestDistance() 메서드와 내용이 중복되군요. startStationInfo, endStationInfo를 만드는 부분을 메서드로 만들면 어떨까요?
| return graphService.getTotalShortestDistanceAndShortestTime(path); | ||
| } | ||
|
|
||
| private void savetotalInfo(final List<Integer> totalInfo){ |
There was a problem hiding this comment.
여기도 낙타표기법으로 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.
이 부분에서 Validator를 상속해주는 것은 큰 상관 없을것 같아요! isBlank() 메서드는 공통 로직이니까요~
하지만 Validator 해야 할 클래스가 100개 있다고 가정해볼게요. 그럼 그만큼 공통 검증 사항을 뽑기는 쉽지 않을거예요...
그럴 때는 extends 대신 implements으로 구현해보는 것도 방법이 될 것 같아요!!
No description provided.