-
Notifications
You must be signed in to change notification settings - Fork 0
[1주차] 정재우 #2
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
Open
holyPigeon
wants to merge
69
commits into
main
Choose a base branch
from
holyPigeon
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[1주차] 정재우 #2
Changes from all commits
Commits
Show all changes
69 commits
Select commit
Hold shift + click to select a range
493087b
docs: 기능 구현 목록 정리
holyPigeon 807e9f0
docs: 기능 구현 목록 수정
holyPigeon 37d9851
feat: Player 클래스 생성
holyPigeon 4028c94
feat: Player 클래스 필드 변수 구현
holyPigeon 648b947
feat: NumberService 클래스 생성
holyPigeon e1e0285
feat: 컴퓨터의 숫자를 랜덤하게 정하는 메소드 구현
holyPigeon 8dcbb93
feat: ViewService 클래스 생성
holyPigeon 8fb5fc5
feat: 사용자 숫자 입력 메시지 출력 메소드 구현
holyPigeon 7ecdc24
docs: 기능 구현 목록 수정
holyPigeon 4557577
feat: 사용자 숫자 입력 메소드 구현
holyPigeon 7875953
feat: NumberUtil 클래스 생성
holyPigeon 74b7530
feat: 입력된 문자열이 비어있지 않은지 검증하는 메소드 구현
holyPigeon f854531
feat: 입력된 문자열의 길이가 3인지 검증하는 메소드 구현
holyPigeon 3f842a4
feat: 입력된 문자열이 정수인지 검증하는 메소드 구현
holyPigeon a1d9bb8
feat: 입력된 문자열이 양의 정수인지 검증하는 메소드 구현
holyPigeon 3fa283b
docs: 기능 구현 목록 수정
holyPigeon 9a41677
feat: 문자열 타입의 숫자를 리스트로 변환하는 메소드 구현
holyPigeon b8ae0d1
feat: 문자열 타입의 숫자를 리스트로 변환하는 메소드 구현
holyPigeon e883167
feat: 입력된 정수들의 범위가 1부터 9인지 검증하는 메소드 구현
holyPigeon aa87a43
feat: 입력된 정수들의 범위가 1부터 9인지 검증하는 메소드 구현
holyPigeon 0ccd0a5
feat: 입력값을 전체적으로 검증하는 메소드 구현
holyPigeon 7beebcb
feat: NumberUtil 클래스 protected 생성자 적용
holyPigeon 18a85ad
feat: 숫자 비교에 따라 힌트를 결정하는 메소드 구현
holyPigeon c2942b9
feat: 숫자 비교에 따라 힌트를 결정하는 메소드 구현
holyPigeon 853499c
feat: 플레이어가 입력한 숫자의 위치를 비교하는 메소드 구현
holyPigeon 21c2c51
feat: 플레이어가 입력한 각 숫자가 컴퓨터의 숫자에 있는지 확인하는 메소드 구현
holyPigeon 61ee655
feat: Hint 클래스 생성
holyPigeon 9f206ba
feat: Hint 클래스 필드 변수 구현
holyPigeon c36a2af
feat: Hint 클래스 생성자 구현
holyPigeon f3b74ef
feat: strike과 ball의 개수를 증가시키는 메소드 구현
holyPigeon b1b5922
feat: strike과 ball이 각각 존재하는지 확인하는 메소드 구현
holyPigeon b85b382
feat: strike이 3개인지 확인하는 메소드 구현
holyPigeon 0a018f2
feat: strike와 ball의 각 개수에 따라 문자열을 반환하는 메소드 구현
holyPigeon 75c32f1
feat: 조건에 따라 문자열을 이어붙여 힌트 문자열을 반환하는 메소드 구현
holyPigeon dece719
feat: 게임 재시작 메시지를 출력하는 메소드 구현
holyPigeon 9c2f5d4
feat: 게임 종료 메시지를 출력하는 메소드 구현
holyPigeon cdf391e
feat: 힌트 메시지를 출력하는 메소드 구현
holyPigeon 58f4c0b
feat: GameController 클래스 생성
holyPigeon a5b561d
feat: GameController 클래스 의존성 주입 로직 구현
holyPigeon 321d147
feat: Player 클래스 getter, setter 메소드 구현
holyPigeon 96ebaa2
feat: 컴퓨터의 숫자를 세팅하는 메소드 구현
holyPigeon 21d8873
feat: 플레이어의 숫자를 세팅하는 메소드 구현
holyPigeon 1cbb840
feat: 야구 게임 진행 메소드 구현
holyPigeon ff10a88
feat: 야구 게임 시작 메소드 구현
holyPigeon 95a5942
feat: 야구 게임 어플리케이션 실행 로직 구현
holyPigeon 975ac74
docs: 리팩토링 목록 작성
holyPigeon 204baf0
docs: 기존 과제 설명 및 요구 사항 제거
holyPigeon 5407aee
refector: 숫자 비교에 따른 힌트 설정 로직 최적화
holyPigeon 2c5dae8
refector: 일부 for문을 stream 메소드를 사용하여 간소화
holyPigeon fb9aea7
fix: 정수 범위 검증 로직에서 발생하는 에러 수정
holyPigeon aecfe0d
docs: README.md와 docs/README.md의 혼용 수정
holyPigeon 3f10741
refector: Hint 클래스 관련 힌트 메시지 목록을 Enum으로 분리
holyPigeon 2aa4de1
refector: 입력값 검증 시 발생하는 예외의 목록을 Enum으로 분리
holyPigeon 922610b
refector: strike 및 ball 개수에 따른 상태 반환 메소드 최적화
holyPigeon 5d5e377
refector: 입력값 검증 시의 검증 조건들을 Enum으로 분리
holyPigeon f77d26f
refector: View 계층에서 출력하는 시스템 메시지의 목록을 Enum으로 분리
holyPigeon c4916ee
refector: ViewService의 기능을 InputView와 OutputView로 각각 분리
holyPigeon 3d8960f
fix: 정수 범위 검증 로직에서 발생하는 에러 수정
holyPigeon 80ff667
feat: 문자열을 정수 타입의 리스트로 변환하는 유틸 메소드 구현
holyPigeon fc2dcab
feat: Player 클래스의 setter를 제거하고 생성 시에만 필드 변수값을 정할 수 있도록 수정
holyPigeon f4218a0
fix: 리스트를 문자열로 변환하는 유틸 메소드가 제대로 동작하지 않는 오류 수정
holyPigeon 4b785df
refector: 싱글톤 패턴 적용
holyPigeon 56702e5
refector: ViewService 클래스 삭제
holyPigeon 7c7cfda
refector: GameController의 메소드명을 명시적으로 변경
holyPigeon e205988
refector: 힌트 생성 시의 숫자 비교 로직 메소드 분리
holyPigeon 2fd7397
refector: 힌트 생성 메소드명을 명시적으로 변경
holyPigeon df1279b
refector: Player 객체를 불변 객체로 만들기 위한 로직 구현
holyPigeon 67b34c9
refector: 게임 종료 및 재시작 enum 추가 구현
holyPigeon 7adc68e
refector: 게임 실행 조건을 가독성 향상을 위해 메소드로 분리
holyPigeon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # 미션 - 숫자 야구 | ||
|
|
||
| ## ✅ 기능 구현 목록 | ||
|
|
||
| ### 게임 준비 | ||
|
|
||
| - [x] 컴퓨터의 숫자를 랜덤하게 정한다. | ||
|
|
||
| ### 게임 진행 | ||
|
|
||
| - [x] 플레이어의 숫자를 입력받는다. | ||
| - [x] 숫자를 입력받는다. | ||
| - [x] 문자열 타입의 숫자를 리스트로 변환한다. | ||
| - [x] 입력값을 검증한다. | ||
| - [x] 입력된 문자열이 비어있지 않은지 검증한다. | ||
| - [x] 입력된 문자열의 길이가 3인지 검증한다. | ||
| - [x] 입력된 문자열이 정수인지 검증한다. | ||
| - [x] 입력된 문자열이 양의 정수인지 검증한다. | ||
| - [x] 입력된 정수들의 범위가 1부터 9인지 검증한다. | ||
| - [x] 입력된 정수들이 서로 다른 수인지 검증한다. | ||
| - [x] 입력값이 부적절한 경우, 예외를 반환한다. | ||
|
|
||
|
|
||
| - [x] 플레이어가 입력한 숫자와 컴퓨터의 숫자를 비교한다. | ||
| - [x] 플레이어가 입력한 각 숫자가 컴퓨터의 숫자에 있는지 확인한다. | ||
| - [x] 플레이어가 입력한 숫자와 위치를 비교한다. | ||
| - [x] 숫자 비교에 따라 힌트를 결정한다. | ||
|
|
||
|
|
||
| - [x] 결정된 힌트를 출력한다. | ||
| - [x] 플레이어가 숫자를 맞추지 못한 경우, 다시 `게임 준비`로 돌아가 숫자를 입력받는다. | ||
| - [x] 플레이어가 3개의 숫자를 모두 맞췄다면 게임을 다시 시작할 지, 종료할 지 결정한다. | ||
| - [x] "1"을 누르면 게임을 다시 시작, "2"를 누르면 게임을 종료한다. | ||
|
|
||
| --- | ||
|
|
||
| ## 🛠️ 리팩토링 목록 | ||
|
|
||
| ### 실행 로직 간소화 및 성능 향상 | ||
|
|
||
| - [x] 숫자 비교에 따른 힌트 설정 로직을 간소화하고 성능을 향상시킨다. | ||
| - [x] for문을 stream 메소드를 사용하여 간소화한다. | ||
|
|
||
| ### 일부 변수들의 상수 변환 | ||
|
|
||
| - [x] Hint 클래스 관련 힌트 목록을 Enum으로 분리한다. | ||
| - [x] 입력값 검증 시의 검증 조건들을 Enum으로 분리한다. | ||
| - [x] 입력값 검증 시 발생하는 예외의 목록을 Enum으로 분리한다. | ||
| - [x] View 계층에서 출력하는 메시지의 목록을 Enum으로 분리한다. | ||
|
|
||
| ### getter 및 setter 제거 | ||
|
|
||
| - [x] Player 클래스의 getter 및 setter를 제거하고 비즈니스 로직을 도메인 내에 구현한다. | ||
| - [x] Player 클래스의 setter를 제거하고 생성 시에만 필드 변수값을 정할 수 있도록 한다. | ||
| - [x] Player 클래스의 getter를 제거하고 비즈니스 로직을 도메인 내에 구현한다. | ||
|
|
||
| ### 기타 | ||
|
|
||
| - [x] ViewService의 기능을 InputView와 OutputView로 각각 분리한다. | ||
| - [x] NumberService와 InputView, OutputView에 싱글톤 패턴을 적용한다. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,10 @@ | ||
| package baseball; | ||
|
|
||
| import baseball.controller.GameController; | ||
|
|
||
| public class Application { | ||
| public static void main(String[] args) { | ||
| // TODO: 프로그램 구현 | ||
| GameController game = new GameController(); | ||
| game.run(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| package baseball.application; | ||
|
|
||
| import baseball.domain.Hint; | ||
| import baseball.domain.Player; | ||
| import camp.nextstep.edu.missionutils.Randoms; | ||
| import java.util.ArrayList; | ||
| import java.util.HashSet; | ||
| import java.util.List; | ||
| import java.util.Objects; | ||
| import java.util.Set; | ||
|
|
||
| public class NumberService { | ||
|
|
||
| private static final NumberService instance = new NumberService(); | ||
|
|
||
| public static NumberService getInstance() { | ||
| return instance; | ||
| } | ||
|
|
||
| public List<Integer> getRandomNumber() { | ||
| Set<Integer> numberSet = new HashSet<>(); | ||
| while (numberSet.size() < 3) { | ||
| numberSet.add(Randoms.pickNumberInRange(1, 9)); | ||
| } | ||
|
|
||
| return new ArrayList<>(numberSet); | ||
| } | ||
|
|
||
| public Hint generateHint(Player computer, Player player) { | ||
| List<Integer> computerNumber = computer.getNumberList(); | ||
| List<Integer> playerNumber = player.getNumberList(); | ||
| Hint hint = new Hint(); | ||
|
|
||
| compareNumber(computerNumber, playerNumber, hint); | ||
|
|
||
| return hint; | ||
| } | ||
|
|
||
| private static void compareNumber(List<Integer> computerNumber, List<Integer> playerNumber, Hint hint) { | ||
| for (int i = 0; i < playerNumber.size(); i++) { | ||
| Integer myNumber = playerNumber.get(i); | ||
| if (isStrike(computerNumber, i, myNumber)) { | ||
| hint.increaseStrike(); | ||
| } else if (isBall(computerNumber, myNumber)) { | ||
| hint.increaseBall(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private static boolean isBall(List<Integer> computerNumber, Integer myNumber) { | ||
| return computerNumber.contains(myNumber); | ||
| } | ||
|
|
||
| private static boolean isStrike(List<Integer> computerNumber, int i, Integer myNumber) { | ||
| return Objects.equals(myNumber, computerNumber.get(i)); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package baseball.constant; | ||
|
|
||
| public enum ErrorMessage { | ||
|
|
||
| INPUT_EMPTY("입력값은 비어있지 않아야 합니다."), | ||
| INPUT_LENGTH_INVALID("입력값은 3자리이어야 합니다."), | ||
| INPUT_NUMBER_NOT_INTEGER("입력값은 정수이어야 합니다."), | ||
| INPUT_NUMBER_NOT_POSITIVE_INTEGER("입력값은 양의 정수이어야 합니다."), | ||
| INPUT_NUMBER_NOT_IN_RANGE("입력되는 각 숫자는 1 이상 9 이하의 정수로 이루어져야 합니다."), | ||
| INPUT_NUMBER_NOT_UNIQUE("입력되는 각 숫자는 서로 다른 숫자이어야 합니다."); | ||
|
|
||
|
|
||
| private final String message; | ||
|
|
||
|
|
||
| ErrorMessage(String message) { | ||
| this.message = message; | ||
| } | ||
|
|
||
| public String getMessage() { | ||
| return message; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package baseball.constant; | ||
|
|
||
| public enum HintMessage { | ||
|
|
||
| ONLY_BALL("%d볼"), | ||
| ONLY_STRIKE("%d스트라이크"), | ||
| NOTHING("낫싱"); | ||
|
|
||
| private final String message; | ||
|
|
||
|
|
||
| HintMessage(String message) { | ||
| this.message = message; | ||
| } | ||
|
|
||
| public String getMessage() { | ||
| return message; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package baseball.constant; | ||
|
|
||
| public enum SystemMessage { | ||
|
|
||
| TYPE_NUMBER("숫자를 입력해주세요 : "), | ||
| GAME_END("3개의 숫자를 모두 맞히셨습니다! 게임 종료"), | ||
| GAME_RESTART("게임을 새로 시작하려면 1, 종료하려면 2를 입력하세요."), | ||
| EXIT_FLAG("1"), | ||
| RESTART_FLAG("2"); | ||
|
|
||
| private final String message; | ||
|
|
||
| SystemMessage(String message) { | ||
| this.message = message; | ||
| } | ||
|
|
||
| public String getMessage() { | ||
| return message; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| package baseball.controller; | ||
|
|
||
| import static baseball.constant.SystemMessage.RESTART_FLAG; | ||
| import static baseball.util.NumberUtil.convertStringToList; | ||
|
|
||
| import baseball.application.NumberService; | ||
| import baseball.domain.Hint; | ||
| import baseball.domain.Player; | ||
| import baseball.view.InputView; | ||
| import baseball.view.OutputView; | ||
| import java.util.Objects; | ||
|
|
||
| public class GameController { | ||
|
|
||
| private final NumberService numberService = NumberService.getInstance(); | ||
| private final InputView inputView = InputView.getInstance(); | ||
| private final OutputView outputView = OutputView.getInstance(); | ||
|
|
||
| public void run() { | ||
| do { | ||
| Player computer = prepareComputer(); | ||
|
|
||
| play(computer); | ||
|
|
||
| } while (isGameRestarted()); // 종료(2)를 누르지 않으면 게임을 다시 시작한다. | ||
| } | ||
|
|
||
| private void play(Player computer) { | ||
| while (true) { | ||
| Player player = preparePlayer(); | ||
|
|
||
| Hint hint = numberService.generateHint(computer, player); // 컴퓨터와 플레이어의 숫자를 비교하여 힌트를 얻는다. | ||
| outputView.printHintMessage(hint); // 힌트를 출력, 만약 숫자가 맞는다면 게임 종료 메시지도 출력한다. | ||
| if (hint.isThreeStrike()) { // 숫자를 맞췄다면 끝낸다. | ||
| break; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private boolean isGameRestarted() { | ||
| return !Objects.equals(inputView.readNumber(), RESTART_FLAG.getMessage()); | ||
| } | ||
|
|
||
| private Player prepareComputer() { | ||
| return new Player(numberService.getRandomNumber()); | ||
| } | ||
|
|
||
| private Player preparePlayer() { | ||
| outputView.printReadMessage(); | ||
| return new Player(convertStringToList(inputView.readNumber())); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| package baseball.domain; | ||
|
|
||
| import static baseball.constant.HintMessage.NOTHING; | ||
| import static baseball.constant.HintMessage.ONLY_BALL; | ||
| import static baseball.constant.HintMessage.ONLY_STRIKE; | ||
| import static java.lang.String.format; | ||
| import static java.lang.String.join; | ||
|
|
||
| import java.util.ArrayList; | ||
|
|
||
| public class Hint { | ||
|
|
||
| private int strike; | ||
|
|
||
| private int ball; | ||
|
|
||
| public Hint() { | ||
| strike = 0; | ||
| ball = 0; | ||
| } | ||
|
|
||
| public void increaseStrike() { | ||
| strike++; | ||
| } | ||
|
|
||
| public void increaseBall() { | ||
| ball++; | ||
| } | ||
|
|
||
| public boolean isHintNothing() { | ||
| return isStrikeExist() && isBallExist(); | ||
| } | ||
|
|
||
| public boolean isStrikeExist() { | ||
| return strike > 0; | ||
| } | ||
|
|
||
| public boolean isBallExist() { | ||
| return ball > 0; | ||
| } | ||
|
|
||
| public boolean isThreeStrike() { | ||
| return strike == 3; | ||
| } | ||
|
|
||
| public String toString() { | ||
| ArrayList<String> resultString = new ArrayList<>(); | ||
| if (!isBallExist() && !isStrikeExist()) { | ||
| return getNothingString(); | ||
| } | ||
| if (isBallExist()) { | ||
| resultString.add(getBallString()); | ||
| } | ||
| if (isStrikeExist()) { | ||
| resultString.add(getStrikeString()); | ||
| } | ||
| return join(" ", resultString); | ||
| } | ||
|
|
||
| public String getStrikeString() { | ||
| return format(ONLY_STRIKE.getMessage(), strike); | ||
| } | ||
|
|
||
| public String getBallString() { | ||
| return format(ONLY_BALL.getMessage(), ball); | ||
| } | ||
|
|
||
| public String getNothingString() { | ||
| return NOTHING.getMessage(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package baseball.domain; | ||
|
|
||
| import static baseball.util.NumberUtil.convertListToString; | ||
| import static baseball.util.NumberUtil.validate; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
|
|
||
| public class Player { | ||
|
|
||
| private final List<Integer> numberList; | ||
|
|
||
| public Player(List<Integer> numbers) { | ||
| validate(convertListToString(numbers)); | ||
| this.numberList = new ArrayList<>(numbers); | ||
| } | ||
|
|
||
| public List<Integer> getNumberList() { | ||
| return Collections.unmodifiableList(numberList); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
NumberService, ViewService는 멤버변수가 없는 객체인 것 같아요.
멤버변수가 없는 객체를 new로 생성해야만 하는 이유가 있는지 궁금합니다!
만약 뾰족한 이유가 없다면, static으로 처리해서 생성자로 생성하는 부분을 해치워도 좋을 것 같구요!
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.
별 생각 없이 의존성 주입을 생각하고 저렇게 코드를 짰었는데 다시보니 딱히 저럴 필요가 없었던 것 같네요. 말씀하신 것처럼 static 처리하는 게 나을 것 같습니다...! 찾아보니까 이런 식으로 인스턴스를 한 개만 생성하는 게 싱글톤 패턴이라고 하네요. 이름만 많이 들어봤는데 이번에 배우고 갑니다!