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

[4기-황준호] View 패키지 생성 및 구현 #739

Open
wants to merge 27 commits into
base: juno-junho
Choose a base branch
from

Conversation

juno-junho
Copy link

📌 과제 설명

👩‍💻 요구 사항과 구현 내용

  • 입력을 받는 InputView와 출력을 담당하는 OutputView를 필드로 갖는 Console 클래스를 생성했습니다.
  • Input은 BufferedReader를 통해 받습니다
  • Output은 Logger를 통해 출력합니다.

✅ 피드백 반영사항

  • 추가 예정

✅ PR 포인트

  • controller에서 의존하는 객체 수를 줄이고자, InputView와 OutputView를 묶어 Console 객체로 관리했습니다.

🟣 궁금한 점

  • view에서 여러 출력메세지들이 있을때, 이런 것들을 상수로 해당 클래스에서 관리하는 것이 좋을지 아니면 Messages 라는 Enum을 통해서 관리하는 것이 좋을지 궁금합니다.
    지금은 어떻게 관리해야할지 판단이 서지 않아 상수로 분리 시키지 않은 것도 있습니다.

@juno-junho
Copy link
Author

변경된 파일은 다음과 같습니다

  • view 패키지의 세 파일

Copy link
Contributor

@devcourse-ray devcourse-ray left a comment

Choose a reason for hiding this comment

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

👍

Comment on lines +51 to +56
if (voucherType == 1) {
outputView.print("할인할 금액을 입력하세요.");
}
if (voucherType == 2) {
outputView.print("할인율을 입력하세요 (1% ~ 100%)");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

분기처리를 고민해보세요

Comment on lines 29 to 31
public void printStartMessage() {
outputView.print(START_MESSAGE);
}
Copy link

Choose a reason for hiding this comment

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

START_MESSAGE는 printStartMessage에만 쓰이고 있는데, 굳이 변수로 뺴야할 이유가 있을까요?

Copy link
Author

Choose a reason for hiding this comment

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

그럼 메서드 안에 그냥 놔두는게 나을까요?
매직넘버 상수로 분리하는 느낌으로 분리했습니다!

if (voucherType == 2) {
outputView.print("할인율을 입력하세요 (1% ~ 100%)");
}
return StringUtil.convertStringToInt(inputView.read());
Copy link

Choose a reason for hiding this comment

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

Suggested change
return StringUtil.convertStringToInt(inputView.read());
return StringUtil.convertStringToInt(read());

Copy link

@ICCHOI ICCHOI left a comment

Choose a reason for hiding this comment

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

InputView와 OutputView로 책임을 분리한 것 치고는 Console의 로직이 너무 복잡하다는 느낌이 들어요.
좀 더 추상화에 대해 고민해보시죠...!

@juno-junho juno-junho marked this pull request as draft July 4, 2023 05:15
@juno-junho
Copy link
Author

InputView와 OutputView로 책임을 분리한 것 치고는 Console의 로직이 너무 복잡하다는 느낌이 들어요. 좀 더 추상화에 대해 고민해보시죠...!

인창님 죄송한데 도저히 감이 잡히질 않습니다 ㅠㅠ
InputView와 OutputView를 console로 합친것 만으로도 Controller에서의 필드 수를 줄이기 위해서 한 조치이고, controller에서 console로 메세지를 보내 값을 가지고 오는 방식으로 의미있는 메서드 이름을 정하고 그렇게 작성했는데 어떻게 더 추상화를 하는게 좋을까요?

@juno-junho juno-junho marked this pull request as ready for review July 8, 2023 11:38
@juno-junho juno-junho requested a review from ICCHOI July 8, 2023 11:38
Copy link

@ICCHOI ICCHOI left a comment

Choose a reason for hiding this comment

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

Console 같은 경우에는
Voucher와 관계 없이 순수하게 Console의 역할을 하는 메소드와 ex) read(), print()
Voucher와 관련된 메소드들이 뒤섞여 있다는 느낌이 들어,
이 둘을 분리해서 사용할 수 있다면 좀 더 객체지향적일 수 있겠다는 생각이 들었어요.

하지만 이렇게 하기 힘들다면 VoucherConsole과 같은 바우처와 관련된 기능을 하는 콘솔이라고 이름을 바꾸면 좋을 것 같아요.

Comment on lines +34 to +36
int voucherType = console.readVoucherTypeToCreate();
int discountAmount = console.readVoucherDiscountAmount(voucherType);
int voucherAmount = console.readVoucherAmountToCreate();
Copy link

Choose a reason for hiding this comment

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

저는 값을 입력 받는 것이 console의 역할이라고 생각하고,
이 값들이 어떤 의미를 가지는지는 알 필요 없다고 생각해요.
VoucherType, VoucherDiscountAmount, VoucherAmount의 값은 console이 아닌 해당 객체를 사용하거나 검증할 책임이 있는 객체에서 진행하는게 맞다고 생각합니다.

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

Successfully merging this pull request may close these issues.

3 participants