Open
Conversation
HyunwooKiim
reviewed
Sep 29, 2025
2/src/Stock.java
Outdated
| Item i = new Item(name, item, quantity, price, link); | ||
| items.saveItem(i); | ||
| System.out.println("성공적으로 신청되었습니다."); | ||
| } else if (inp=="2") { |
Contributor
There was a problem hiding this comment.
자바에서 문자열 비교는 .equals를 사용합니다.
Suggested change
| } else if (inp=="2") { | |
| } else if (inp.equals("2")) { |
2/src/Stock.java
Outdated
| } | ||
|
|
||
| public String getItem() { | ||
| return String.format("신청자: %s, 물품명: %s, 수량: %d, 가격: %d, 구매링크: %s", name, item, quantity, price, link); |
Contributor
There was a problem hiding this comment.
한줄로 되어있어서 출력 가독성이 떨어짐
Suggested change
| return String.format("신청자: %s, 물품명: %s, 수량: %d, 가격: %d, 구매링크: %s", name, item, quantity, price, link); | |
| return String.format( | |
| "신청자: %s, 물품명: %s, 수량: %d, 가격: %d, 구매링크: %s", | |
| name, item, quantity, price, link | |
| ); |
2/src/Stock.java
Outdated
| } | ||
| } | ||
|
|
||
| class Checker { |
Contributor
There was a problem hiding this comment.
클래스 명은 StockValidator을 추천함
Contributor
There was a problem hiding this comment.
개선사항 :
SRP -> Stock이 UI와 로직을 다 가지고 있음
DIP -> Stock이 구체 클래스에 직접 의존
개선법 :
SRP ->
- UI 담당 (StockUI)
- 메뉴 출력, 입력만 담당.
- 애플리케이션 흐름 담당 (StockApp)
- UI에서 입력받은 값을 해석하고, Store와 Validator를 호출하는 역할.
- 검증/저장은 기존대로 유지.
DIP ->
Store 인터페이스를 두고, Stock은 이 인터페이스에만 의존하게 하기.
예시 :
interface ItemStore {
void saveItem(Item item);
Item[] getItems();
int getSize();
}인터페이스를 많이많이 사용합시다.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.