Skip to content

[1202 강태은] Backend 2번 과제 제출합니다.#3

Open
Blue-Leaf-vm wants to merge 4 commits intoARA-INTERN:mainfrom
Blue-Leaf-vm:two
Open

[1202 강태은] Backend 2번 과제 제출합니다.#3
Blue-Leaf-vm wants to merge 4 commits intoARA-INTERN:mainfrom
Blue-Leaf-vm:two

Conversation

@Blue-Leaf-vm
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown
Contributor

@HyunwooKiim HyunwooKiim left a comment

Choose a reason for hiding this comment

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

일단 이정도만 봐주시면 될듯

2/src/Stock.java Outdated
Item i = new Item(name, item, quantity, price, link);
items.saveItem(i);
System.out.println("성공적으로 신청되었습니다.");
} else if (inp=="2") {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

자바에서 문자열 비교는 .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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

한줄로 되어있어서 출력 가독성이 떨어짐

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
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

이게 훨씬 보기 좋죠?

2/src/Stock.java Outdated
}
}

class Checker {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

클래스 명은 StockValidator을 추천함

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

이걸 더 많이써요

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

개선사항 :
SRP -> Stock이 UI와 로직을 다 가지고 있음
DIP -> Stock이 구체 클래스에 직접 의존
개선법 :
SRP ->

  1. UI 담당 (StockUI)
  • 메뉴 출력, 입력만 담당.
  1. 애플리케이션 흐름 담당 (StockApp)
  • UI에서 입력받은 값을 해석하고, Store와 Validator를 호출하는 역할.
  1. 검증/저장은 기존대로 유지.
    DIP ->
    Store 인터페이스를 두고, Stock은 이 인터페이스에만 의존하게 하기.
    예시 :
interface ItemStore {
    void saveItem(Item item);
    Item[] getItems();
    int getSize();
}

인터페이스를 많이많이 사용합시다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants