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

[럿고] 치킨집 미션 제출합니다. #5

Open
wants to merge 29 commits into
base: tdd-rutgo
Choose a base branch
from

Conversation

ksy90101
Copy link

@ksy90101 ksy90101 commented Jun 27, 2020

와.. 진심 너무 어렵네요 ㅠㅠ
웹 처럼 하려다가 완전 망한거 같아요...
마음껏 까주시면 감사하겠습니다!

pobiconan and others added 26 commits April 10, 2020 13:14
Copy link

@KS-KIM KS-KIM left a comment

Choose a reason for hiding this comment

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

안녕하세요 럿고.
치킨집 미션 잘 구현해 주셨네요.
간단한 피드백 남겼으니 궁금한 점 있으시면 DM 남겨주세요.

Comment on lines +33 to +36
private int getTableNumber() {
OutputView.printTables(tableService.findTables());
return InputView.inputTableNumber();
}
Copy link

@KS-KIM KS-KIM Jun 27, 2020

Choose a reason for hiding this comment

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

OrderController에 동일한 메서드가 있는데, 재활용 할 수는 없을까요?

Copy link
Author

@ksy90101 ksy90101 Jun 30, 2020

Choose a reason for hiding this comment

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

웹으로 하려고 하다보니, 이렇게 된거 같아요.ㅠㅠ
웹이였다면 인자로 받아오기만 하면 되기때문에 중복 코드가 발생하지 않았을꺼 같은데...ㅠㅠ
이건 개인적으로 이렇게 남겨두고 싶어요!

Comment on lines 16 to 18
ORDER(1, new OrderController(new MenuService(new MenuRepository()),
new TableService(new TableRepository(), new MenuRepository()))),
PAYMENT(2, new PaymentController(new TableService(new TableRepository(), new MenuRepository()))),
Copy link

@KS-KIM KS-KIM Jun 27, 2020

Choose a reason for hiding this comment

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

매번 새로운 TableRepository, MenuRepository 인스턴스를 생성할 필요가 있을까요?

Comment on lines 24 to 25
Payment payment = Payment.of(paymentNumber);
BigDecimal account = payment.pay(table.getOrderHistories());
Copy link

@KS-KIM KS-KIM Jun 27, 2020

Choose a reason for hiding this comment

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

결제 타입을 식별하고, 테이블에 있는 모든 주문의 가격을 계산하여 지불할 금액을 계산하는 것은 TableService가 가져야 할 역할이 아닐까요? 컨트롤러는 입출력 흐름을 제어하고 서비스에 비즈니스 로직에 대한 수행을 위임하는 것으로 충분한 역할을 하는 것이라고 생각하는데, 럿고는 어떻게 생각하시는지 궁금하네요.

Copy link
Author

Choose a reason for hiding this comment

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

그렇네요... 제가 급하게 하다 보니...ㅎㅎ 변경했습니다!

Comment on lines +26 to +31
public Menu findById(final int number) {
return menus.stream()
.filter(menu -> menu.isSameNumber(number))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("해당 메뉴가 존재하지 않습니다. number = " + number));
}
Copy link

@KS-KIM KS-KIM Jun 27, 2020

Choose a reason for hiding this comment

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

존재하지 않을 수 있는 값이니 Optional 그 자체를 반환해도 될 것 같아요.

return new BigDecimal(String.valueOf(chickenPaymentAmount));
}

private Optional<DisCountStrategy> findDisCountStrategy(Class<? extends DisCountStrategy> disCountStrategy) {
Copy link

Choose a reason for hiding this comment

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

Suggested change
private Optional<DisCountStrategy> findDisCountStrategy(Class<? extends DisCountStrategy> disCountStrategy) {
private Optional<DisCountStrategy> findDiscountStrategy(Class<? extends DisCountStrategy> disCountStrategy) {


@BeforeEach
void setUp() {
table = new Table(1, new ArrayList<>());
Copy link

Choose a reason for hiding this comment

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

빈 리스트를 인자로 넘겨 줄 것이라면, 테이블 번호만 받아서 빈 주문 리스트를 내부적으로 생성해주는 생성자를 가져도 되지 않을까요?

@DisplayName("테이블에 주문내역이 제대로 들어가는지 확인하는 테스트")
@Test
void addOrderHistoryTest() {
MenuRepository menuRepository = new MenuRepository();
Copy link

@KS-KIM KS-KIM Jun 27, 2020

Choose a reason for hiding this comment

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

도메인 테스트인데 persistence layer에 속하는 MenuRepository 클래스가 개입해도 괜찮을까요?
Menu를 제공할 수 있는 Fixture를 만드는 것도 하나의 방법일 것 같아요.

Copy link
Author

Choose a reason for hiding this comment

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

그렇네요

import domain.menu.MenuRepository;

public class OrderHistoryTest {
private final MenuRepository menuRepository = new MenuRepository();
Copy link

@KS-KIM KS-KIM Jun 27, 2020

Choose a reason for hiding this comment

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

도메인 테스트인데 persistence layer에 속하는 MenuRepository 클래스가 개입해도 괜찮을까요?
Menu를 제공할 수 있는 Fixture를 만드는 것도 하나의 방법일 것 같아요.

Copy link
Author

Choose a reason for hiding this comment

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

그렇네용


class OrderHistoriesTest {

private final MenuRepository menuRepository = new MenuRepository();
Copy link

@KS-KIM KS-KIM Jun 27, 2020

Choose a reason for hiding this comment

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

도메인 테스트인데 persistence layer에 속하는 MenuRepository 클래스가 개입해도 괜찮을까요?
Menu를 제공할 수 있는 Fixture를 만드는 것도 하나의 방법일 것 같아요.

Copy link
Author

Choose a reason for hiding this comment

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

그렇네용


@DisplayName("제대로 출력되는지 확인하는 테스트")
@ParameterizedTest
@CsvSource(value = {"CHICKEN:[치킨]", "BEVERAGE:[음료]"}, delimiter = ':')
Copy link

@KS-KIM KS-KIM Jun 27, 2020

Choose a reason for hiding this comment

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

delimiter를 따로 지정하신 특별한 이유가 있나요?
기본 delimiter인 comma(',')를 사용해도 테스트하는데 문제가 없을 것 같거든요.
취향이라면 존중합니다😊

Copy link
Author

Choose a reason for hiding this comment

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

취향... 입니다!

Copy link

@YerinCho YerinCho 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 54 to 59
long beveragePaymentAmount = orderHistories.getOrderHistories()
.stream()
.filter(orderHistory -> orderHistory.isSameCategory(Category.BEVERAGE))
.map(OrderHistory::calculatePaymentAmount)
.mapToLong(n -> n)
.sum();

Choose a reason for hiding this comment

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

Suggested change
long beveragePaymentAmount = orderHistories.getOrderHistories()
.stream()
.filter(orderHistory -> orderHistory.isSameCategory(Category.BEVERAGE))
.map(OrderHistory::calculatePaymentAmount)
.mapToLong(n -> n)
.sum();
long beveragePaymentAmount = orderHistories.getOrderHistories()
.stream()
.filter(orderHistory -> orderHistory.isSameCategory(Category.BEVERAGE))
.mapToLong(OrderHistory::calculatePaymentAmount)
.sum();

Comment on lines 52 to 53
.map(OrderHistory::calculatePaymentAmount)
.mapToLong(n -> n)

Choose a reason for hiding this comment

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

Suggested change
.map(OrderHistory::calculatePaymentAmount)
.mapToLong(n -> n)
.mapToLong(OrderHistory::calculatePaymentAmount)

return disCountStrategies.stream()
.filter(disCountStrategyValue -> disCountStrategyValue.getClass() == disCountStrategy)
.findFirst();
}

Choose a reason for hiding this comment

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

알트 의견 동의합니다~ 우선 보이는건
calculatePaymentAmountOfChicken, calculatePaymentAmountOfBeverage, findDisCountStrategy 정도 , ,?

Comment on lines 26 to 27
.map(OrderHistory::getQuantity)
.mapToInt(n -> n)

Choose a reason for hiding this comment

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

Suggested change
.map(OrderHistory::getQuantity)
.mapToInt(n -> n)
.mapToInt(OrderHistory::getQuantity)

assertThatThrownBy(() -> orderHistories.add(new OrderHistory(chicken, 100)))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("한 메뉴당 99까지만 주문할 수 있습니다. menu = [치킨] 1 - 후라이드 : 16000원");
}

Choose a reason for hiding this comment

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

처음 주문할 때 99개를 주문하면 주문이 잘 안되네요 ㅜㅜ
테스트 케이스 추가하면서 수정해주시면 좋을 것 같아요~

Copy link
Author

Choose a reason for hiding this comment

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

조건을 잘못줬어요 ㅠㅠ 수정했습니다!

@@ -0,0 +1,53 @@
package domain.table;

Choose a reason for hiding this comment

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

패키지를 옮겼지만 기존 domain 내에 있던 Table, TableRepo, Menu, MenuRepo가 아직 남아있는 것 같아요~

Copy link
Author

Choose a reason for hiding this comment

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

2019로 진행해서 머지하면서 들어간거 같아요! 삭제했습니다!

assertThatThrownBy(() -> orderHistories.add(new OrderHistory(chicken, 100)))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("한 메뉴당 99까지만 주문할 수 있습니다. menu = [치킨] 1 - 후라이드 : 16000원");
}

Choose a reason for hiding this comment

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

처음 99개 미만으로 주문하고, 그 다음 주문 수를 더한 합계가 99개를 넘는 경우 예외처리가 안 되어 있어요!
테스트 추가하고 프로덕션 코드에도 추가해주세요~

Copy link
Author

Choose a reason for hiding this comment

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

로직이 잘못되었네요 ㅠㅠ 수정햇습니다!

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