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

[둘리] 2단계 로또 제출합니다. #28

Merged
merged 71 commits into from
Feb 23, 2023

Conversation

hyemdooly
Copy link

안녕하세요, 리뷰어님! 수동 기능을 추가하여 코드를 완성했습니다.
피드백 부탁드립니다!

re4rk and others added 30 commits February 14, 2023 15:38
Copy link

@vagabond95 vagabond95 left a comment

Choose a reason for hiding this comment

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

큰 구조 변경 없이 요구사항을 잘 구현해주셨네요 👍 👍

추가로 고민해볼 점에 대해 코멘트 남겼는데 확인 부탁드립니다 :)

src/main/kotlin/domain/Count.kt Outdated Show resolved Hide resolved

fun toInt() = count

operator fun times(number: Int): Int = number * count

Choose a reason for hiding this comment

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

각각의 원시값 포장 클래스에 operator overloading 활용해주시는 시도 좋습니다 👍
다만, operator overloading 의 리턴 타입은 감싸고 있는 원시값이 아닌 해당 클래스로 정의해보는 것은 어떨까요?

Count * Count 를 하였는데 Count 가 아닌 원시값이 리턴된다면, 리턴결과를 쉽게 예측하기 어려울 것 같아요. (int 인지? float 인지?.. etc)

Copy link
Author

@hyemdooly hyemdooly Feb 21, 2023

Choose a reason for hiding this comment

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

피드백 주신대로 원시값이 아닌 해당 클래스(Count 또는 Amount)로 리턴하도록 시도해보았는데요!
기본 생성자에서 유효값 검증하는 과정이 있다보니, 연산 결과가 검증에서 걸리는 경우 문제가 생겼습니다.ㅠㅠ
ex) 구매금액을 로또 가격(1000원)으로 나누는 경우, 1000이상~100000이하가 아니라서 예외가 throw됩니다.

오버로딩을 하지 않고 함수 이름을 timesToNumber와 같이 리턴타입을 함수에 명시해주는건 어떨까요?
아니면 클래스가 갖고 있는 변수(count, amount)의 private를 풀고 controller에서 직접 꺼내서 계산하도록 하는게 좋을까요? 이 방법으로 우선 수정했는데 더 깔끔한 방법이 있을지 고민되네요..

src/main/kotlin/domain/LottoStore.kt Outdated Show resolved Hide resolved
src/main/kotlin/view/OutputView.kt Outdated Show resolved Hide resolved
src/main/kotlin/view/InputView.kt Outdated Show resolved Hide resolved
Copy link

@vagabond95 vagabond95 left a comment

Choose a reason for hiding this comment

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

요구사항을 대부분 빠르게 반영해주셨네요 👍

count 와 관련하여 질문 주신 내용에 대한 코멘트 남겼는데, 확인 부탁드릴게요 :)

fun toInt() = count

operator fun times(number: Int): Int = number * count

Choose a reason for hiding this comment

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

timesToNumber 와 같이 스스로 클래스가 처리할 수 있는 접근 방식도 좋은 것 같아요!

반면 controller 의 경우 view 와 model 을 중계하는 로직 외에는 최대한 안넣는 방향으로 해보는건 어떨까요? controller 가 비즈니스 로직에 대해 알고 있는 영역이 많아질수록 model 과의 경계가 희미해질 수 있을 것 같아요.

Choose a reason for hiding this comment

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

추가로,

 require((amount / LOTTO_PRICE).toInt() >= count) { ERROR_NUMBER_RANGE.format(count) }

이 검증이 count 내부에서 꼭 진행되어야하는 것인지 고민해봐도 좋을 것 같아요.
count 에 넘어오는 실제 value 에 대한 검증과 count 와 연관된 검증을 구분해볼 수 있지 않을까요? :)

Copy link

@vagabond95 vagabond95 left a comment

Choose a reason for hiding this comment

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

추가적으로 코멘트 드릴 부분이 보이지 않습니다 👍
작업 단위별 커밋로그, 테스트 코드로 검증 및 구현 방식도 좋았습니다!

로또 미션 진행하시느라 고생 많으셨어요.
해당 미션을 통해 얻어가는 것이 있으셨길 바랍니다 :)

남은 미션도 화이팅이십니다!

package domain

class LottoCalculator(private val price: Int) {
fun getAutoCount(amount: Amount, manualCount: Count): Count {

Choose a reason for hiding this comment

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

Amount 에 대한 계산로직이 잘 분리되었네요!

@vagabond95 vagabond95 merged commit cbd338c into woowacourse:hyemdooly Feb 23, 2023
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.

None yet

3 participants