Skip to content
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

[지하철 노선도] 임규리 - 리뷰 부탁드리겠습니다! #124

Open
wants to merge 72 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 71 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
1180179
docs : 리드미 초안을 작성한다. (개요, 기능 목록, 프로그래밍 요구사항)
IM-GYURI Nov 18, 2024
1b58ada
feat : Application에서 AppConfig를 호출한다.
IM-GYURI Nov 18, 2024
ed7bcc1
feat : Line(노선)에 LinkedList<Station> 필드를 추가한다.
IM-GYURI Nov 18, 2024
8018b4b
feat : 노선을 추가할 시, 이미 존재하는 노선 이름이 있는지 검증한 후 추가하도록 로직을 수정한다.
IM-GYURI Nov 18, 2024
0f98043
feat : 역을 추가할 시, 이미 존재하는 역 이름이 있는지 검증한 후 추가하도록 로직을 수정하고 역 이름으로 역 객체를 …
IM-GYURI Nov 18, 2024
a8ef7da
feat : AppConfig 인스턴스를 호출할 시, 초기 설정을 수행하도록 구현한다.
IM-GYURI Nov 18, 2024
d99bc6a
feat : ErrorMessage를 enum으로 구현한다.
IM-GYURI Nov 18, 2024
29ca7cf
feat : 초기 세팅 정보가 담겨 있는 md 파일을 처리하는 FileLoader 구현한다.
IM-GYURI Nov 18, 2024
953cfd3
feat : 입력에 대한 검증을 수행하는 로직을 InputValidator에구현한다.
IM-GYURI Nov 18, 2024
5551abe
docs : 초기 세팅 노선 정보를 가진 md 파일을 추가한다.
IM-GYURI Nov 18, 2024
20cb96d
docs : 초기 세팅 역 정보를 가진 md 파일을 추가한다.
IM-GYURI Nov 18, 2024
601330f
feat : 빌더 패턴을 적용한 검증 로직을 구현한다.
IM-GYURI Nov 18, 2024
314499a
feat : AppConfig를 enum으로 변경한 후, Scanner와 InputView, OutputView, Subwa…
IM-GYURI Nov 18, 2024
7651fb1
feat : Application의 main()에 try-catch문을 추가한다.
IM-GYURI Nov 18, 2024
511894e
feat : ErrorMessage를 추가한다.
IM-GYURI Nov 18, 2024
02346ab
refactor : validateStationsIsMoreThanTwo()의 함수명을 validateStationsIsLe…
IM-GYURI Nov 18, 2024
29a85f0
refactor : validateStationsIsMoreThanTwo()의 함수명을 validateStationsIsLe…
IM-GYURI Nov 18, 2024
a6715fa
feat : Line(노선) 도메인에 역 목록을 불변으로 반환하는 함수를 구현한다.
IM-GYURI Nov 18, 2024
39d2f3b
feat : InputView에 기능 선택을 입력받는 기능을 구현한다.
IM-GYURI Nov 18, 2024
1bfd40a
feat : 메인 화면의 선택 목록을 enum으로 구현한다.
IM-GYURI Nov 18, 2024
189dcee
feat : OutputView를 구현한다.
IM-GYURI Nov 18, 2024
2f3678c
feat : 재입력을 처리하는 RetryHandler를 구현한다.
IM-GYURI Nov 18, 2024
5476e78
feat : 반복되어 사용되는 문구들을 Sentence enum으로 관리한다.
IM-GYURI Nov 18, 2024
7707323
feat : SubwayController가 메인 화면의 4번 선택지와 Q 선택지를 처리하도록 구현한다.
IM-GYURI Nov 18, 2024
e2bb5c4
feat : InputView에 역 등록과 역 삭제를 묻는 기능을 구현한다.
IM-GYURI Nov 18, 2024
903babe
feat : OutputView에 역 관리 화면, 역 등록, 역 삭제, 역 조회 출력을 구현한다.
IM-GYURI Nov 18, 2024
ae7a66c
feat : RetryHandler가 Supplier와 Runnable을 둘 다 처리할 수 있도록 구현한다.
IM-GYURI Nov 18, 2024
9d7524f
feat : StationRepository의 역 삭제 기능을 수정한다.
IM-GYURI Nov 18, 2024
442c8de
feat : SubwayController에 역 관리 기능을 구현한다.
IM-GYURI Nov 18, 2024
7a428fb
feat : 역 관리 화면의 선택지들을 enum으로 관리한다.
IM-GYURI Nov 18, 2024
e998268
feat : ErrorMessage를 추가한다.
IM-GYURI Nov 19, 2024
2eafd89
feat : InputValidator에 이름을 통해 존재하는 역 이름인지 검증하는 로직을 구현한다.
IM-GYURI Nov 19, 2024
4257a0b
feat : InputView에 노선 관리에 관련된 로직을 구현한다.
IM-GYURI Nov 19, 2024
c3124af
feat : LineRepository에 노선 이름으로 노선 객체를 찾아 반환하는 로직을 구현한다.
IM-GYURI Nov 19, 2024
4491b9a
feat : OutputView에 노선 관리와 관련된 출력을 구현한다.
IM-GYURI Nov 19, 2024
45a7498
feat : ErrorMessage를 추가한다.
IM-GYURI Nov 19, 2024
bb8708a
feat : InputValidator에 상행 종점역과 하행 종점역이 중복되는지 검증하는 로직을 구현한다.
IM-GYURI Nov 19, 2024
c2d3429
feat : 지하철 노선도 출력 시 사이마다 공백 라인을 추가하는 로직으로 수정한다.
IM-GYURI Nov 19, 2024
d25207f
docs : 리드미의 기능 목록 중 구현 완료한 것들을 체크한다.
IM-GYURI Nov 19, 2024
5b891cf
refactor : StationFeature를 StationLineFeature로 이름을 변경하낟.
IM-GYURI Nov 19, 2024
a2b1c55
feat : SubwayController에 노선 관리 기능을 구현한다.
IM-GYURI Nov 19, 2024
0b6813c
feat : ErrorMessage를 추가한다.
IM-GYURI Nov 19, 2024
454fe46
feat : InputValidator에 노선의 존재 여부 검증 로직과 구간 순서를 검증하는 로직을 구현한다.
IM-GYURI Nov 19, 2024
1991ff3
feat : 구간 관련 입력 기능을 InputView에 구현한다.
IM-GYURI Nov 19, 2024
a2d7925
feat : LineRepository에 구간 삽입 및 삭제 로직을 구현한다.
IM-GYURI Nov 19, 2024
f068479
feat : 구간 관련 출력 로직을 구현한다.
IM-GYURI Nov 19, 2024
e2a231b
feat : SubwayController에 구간 관리 로직을 구현한다.
IM-GYURI Nov 19, 2024
e15d760
feat : 구간 관리 선택지를 enum SectionFeature으로 관리한다.
IM-GYURI Nov 19, 2024
ef11df4
feat : ErrorMessage를 추가한다.
IM-GYURI Nov 19, 2024
bab3160
feat : InputValidator에 역 이름이 어떠한 노선에 등록되어 있다면 에러 처리를 하는 로직을 구현한다.
IM-GYURI Nov 19, 2024
4f39c4e
feat : SubwayController의 deleteStation()에 해당 역이 어떠한 노선에 등록되어 있지 않은지 검…
IM-GYURI Nov 19, 2024
0d9c3f8
docs : 리드미의 기능 목록 중 구현 완료한 것들을 체크한다.
IM-GYURI Nov 19, 2024
bfd982b
feat : AppConfig에 서비스들을 추가한다.
IM-GYURI Nov 19, 2024
9249d7e
feat : OutputView에 공백 라인을 출력하는 printBlank()를 추가한다.
IM-GYURI Nov 19, 2024
023b2f8
refactor : 비즈니스 로직을 각 service로 이동시킨다.
IM-GYURI Nov 19, 2024
3a4deac
feat : ErrorMessage를 추가한다.
IM-GYURI Nov 19, 2024
e7a6fda
refactor : private 메소드를 package-private으로 변경한다.
IM-GYURI Nov 19, 2024
8cb85e6
style : 공백 라인을 정리한다.
IM-GYURI Nov 19, 2024
6121177
refactor : PREFIX를 상수로 만들어 사용하도록 수정한다.
IM-GYURI Nov 19, 2024
00adc99
refactor : PREFIX와 INFO를 상수로 만들어 사용하도록 수정한다.
IM-GYURI Nov 19, 2024
a56dede
refactor : LineRepository에서 최소 역 개수를 상수로 만들어 사용하도록 수정한다.
IM-GYURI Nov 19, 2024
9307a52
refactor : enum을 constants 패키지로 이동시킨다.
IM-GYURI Nov 19, 2024
590fd99
feat : StationRepository에 역을 초기화하는 로직을 추가한다.
IM-GYURI Nov 19, 2024
d7a3f24
refactor : ValidatorBuilder의 사용되지 않는 함수를 삭제한다.
IM-GYURI Nov 19, 2024
00f7a13
test : FileLoader 테스트를 작성한다.
IM-GYURI Nov 19, 2024
f890958
test : LineRepository 테스트를 작성한다.
IM-GYURI Nov 19, 2024
c650af2
test : LineService 테스트를 작성한다.
IM-GYURI Nov 19, 2024
1d2550e
test : MainService 테스트를 작성한다.
IM-GYURI Nov 19, 2024
1aa7842
test : SectionService 테스트를 작성한다.
IM-GYURI Nov 19, 2024
fb77c33
test : StationRepository 테스트를 작성한다.
IM-GYURI Nov 19, 2024
ca8abcc
test : StationService 테스트를 작성한다.
IM-GYURI Nov 19, 2024
7ba0d80
fix : gradle 버전을 변경한다.
IM-GYURI Nov 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
590 changes: 209 additions & 381 deletions README.md

Large diffs are not rendered by default.

13 changes: 10 additions & 3 deletions src/main/java/subway/Application.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
package subway;

import java.util.Scanner;
import subway.config.AppConfig;
import subway.controller.SubwayController;
import subway.view.OutputView;

public class Application {
public static void main(String[] args) {
final Scanner scanner = new Scanner(System.in);
// TODO: 프로그램 구현
try {
final AppConfig appConfig = AppConfig.INSTANCE;
final SubwayController subwayController = appConfig.getController();
subwayController.start();
} catch (IllegalArgumentException e) {
OutputView.printError(e.getMessage());
}
}
}
29 changes: 29 additions & 0 deletions src/main/java/subway/config/AppConfig.java
Copy link

Choose a reason for hiding this comment

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

enum을 활용하여 controller에 대해 singleton을 보장하는 방식이 인상 깊습니다~!

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package subway.config;

import java.util.Scanner;
import subway.controller.SubwayController;
import subway.service.LineService;
import subway.service.MainService;
import subway.service.SectionService;
import subway.service.StationService;
import subway.view.InputView;
import subway.view.OutputView;

public enum AppConfig {

INSTANCE;

private final Scanner scanner = new Scanner(System.in);
private final InputView inputView = new InputView(scanner);
private final OutputView outputView = new OutputView();
private final MainService mainService = new MainService();
private final StationService stationService = new StationService();
private final LineService lineService = new LineService();
private final SectionService sectionService = new SectionService();
private final SubwayController subwayController = new SubwayController(inputView, outputView, mainService,
Copy link

Choose a reason for hiding this comment

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

저도 프리코스 기간동안 코드리뷰를 하며 알게된 사실인데, 함수 매개변수의 개수가 3개가 넘어가면 안좋다고 합니다. 3개 이하로 줄여보는 것은 어떨까요?

Copy link

Choose a reason for hiding this comment

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

해당 코드는 의존성 주입을 위한 부분이라고 생각되는데, DI를 적용하지 않고 클래스 내부에서 의존성을 직접 생성하는 것을 지향하시는걸까요??

Copy link
Author

Choose a reason for hiding this comment

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

저도 이 부분 의견이 궁금합니다! @kgy1008

stationService, lineService, sectionService);

public SubwayController getController() {
return subwayController;
}
}
31 changes: 31 additions & 0 deletions src/main/java/subway/constants/MainFeature.java
Copy link

Choose a reason for hiding this comment

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

"Q"와 같은 경우 "QUIT" 이라는 의미를 명확하게 부여했지만, 1이나 2와 같은 경우에 상대적으로 명확하지 않은 것 같습니다.
이를 더 명확하게 할 방법에 대해 더 고민해보면 좋을 것 같습니다.

Copy link
Author

Choose a reason for hiding this comment

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

감사합니다! 노선 관리와 역 관리를 한 번에 처리하다 보니 더 명확하지 않은 것도 있는 것 같습니당...
수정한다면 ADD, DELETE, SHOW 등으로 수정할 것 같습니다!

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package subway.constants;

import subway.exception.ErrorMessage;

public enum MainFeature {
SELECT_ONE("1"),
SELECT_TWO("2"),
SELECT_THREE("3"),
SELECT_FOUR("4"),
QUIT("Q");

final String message;

MainFeature(String message) {
this.message = message;
}

@Override
public String toString() {
return message;
}
Comment on lines +18 to +21
Copy link

Choose a reason for hiding this comment

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

저는 getter를 사용하는 것이 메서드 이름을 통해 명확히 "어떤 값(message)을 가져오는지" 드러낼 수 있어 의도에 맞는 함수라고 생각했기 때문에 getter 대신에 toString을 재정의하셔서 사용한 이유가 궁금합니다.

Copy link
Author

Choose a reason for hiding this comment

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

다른 코드에서 이렇게 활용하시는 걸 봐서 따라해 본 것인데, 말씀해주신 부분을 생각해보니 getXXX로 사용하는 편이 의도가 확실할 것 같습니다.


public static MainFeature getFeatureFromInput(String input) {
for (MainFeature feature : MainFeature.values()) {
if (feature.toString().equalsIgnoreCase(input)) {
return feature;
}
}
throw new IllegalArgumentException(ErrorMessage.INVALID_FEATURE.toString());
}
}
29 changes: 29 additions & 0 deletions src/main/java/subway/constants/SectionFeature.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package subway.constants;

import subway.exception.ErrorMessage;

public enum SectionFeature {
SELECT_ONE("1"),
SELECT_TWO("2"),
BACK("B");

final String message;

SectionFeature(String message) {
this.message = message;
}

@Override
public String toString() {
return message;
}

public static SectionFeature getFeatureFromInput(String input) {
for (SectionFeature feature : SectionFeature.values()) {
if (feature.toString().equalsIgnoreCase(input)) {
return feature;
}
}
throw new IllegalArgumentException(ErrorMessage.INVALID_FEATURE.toString());
}
}
30 changes: 30 additions & 0 deletions src/main/java/subway/constants/StationLineFeature.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package subway.constants;

import subway.exception.ErrorMessage;

public enum StationLineFeature {
SELECT_ONE("1"),
SELECT_TWO("2"),
SELECT_THREE("3"),
BACK("B");

final String message;

StationLineFeature(String message) {
this.message = message;
}

@Override
public String toString() {
return message;
}

public static StationLineFeature getFeatureFromInput(String input) {
for (StationLineFeature feature : StationLineFeature.values()) {
if (feature.toString().equalsIgnoreCase(input)) {
return feature;
}
}
throw new IllegalArgumentException(ErrorMessage.INVALID_FEATURE.toString());
}
}
Loading