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단계 - 로또(수동) #589

Open
wants to merge 13 commits into
base: 0923kdh
Choose a base branch
from
Open

4단계 - 로또(수동) #589

wants to merge 13 commits into from

Conversation

0923kdh
Copy link

@0923kdh 0923kdh commented Dec 30, 2022

안녕하세요 리뷰어님
이번에도 꼼꼼한 리뷰 부탁드려요 :)

Copy link

@Flamme1004K Flamme1004K left a comment

Choose a reason for hiding this comment

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

안녕하세요!

step4도 구현 잘하셨습니다! 몇 가지 코멘트를 남겼으니 확인 부탁드릴게요!

화이팅입니다 🥳🥳🥳

Comment on lines +13 to +20
val resultMap = mutableMapOf<LottoTicketResult, Int>()
lottoTicketBundle.lottoTickets.groupingBy { ticket ->
val intersectNumbers = ticket.intersect(winningBallResult.winningBalls)
val isBonusBallMatched = winningBallResult.bonusBall in ticket
LottoTicketResult(intersectNumbers.size, isBonusBallMatched)
}.eachCountTo(resultMap)

return LottoWinningResult(resultMap.toSortedMap(getTicketResultComparator()))

Choose a reason for hiding this comment

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

Suggested change
val resultMap = mutableMapOf<LottoTicketResult, Int>()
lottoTicketBundle.lottoTickets.groupingBy { ticket ->
val intersectNumbers = ticket.intersect(winningBallResult.winningBalls)
val isBonusBallMatched = winningBallResult.bonusBall in ticket
LottoTicketResult(intersectNumbers.size, isBonusBallMatched)
}.eachCountTo(resultMap)
return LottoWinningResult(resultMap.toSortedMap(getTicketResultComparator()))
return lottoTicketBundle.lottoTickets.groupingBy {
val intersectNumbers = it.numbers.intersect(winningBallResult.winningBalls)
val isBonusBallMatched = winningBallResult.bonusBall in it.numbers
LottoTicketResult(intersectNumbers.size, isBonusBallMatched)
}
.eachCount()
.toSortedMap(getTicketResultComparator())
.run {
LottoWinningResult(this)
}

이렇게도 표현이 가능해보이네요~ 😊

그리고 LottoTicketResult를 만드는 부분에 대해서 LottoMachine에서 모두 해결하는 것보다는, LottoTicketResult에게 LottoTicketBundle과 WinningBallResult를 넘겨서 좀 더 객체 협력을 만드는 게 좋지 않을까요?

val numbers: Set<Int> = LottoNumberSelector.select(),
) : Set<Int> by numbers
val numbers: Set<LottoNumber>,
) : Set<LottoNumber> by numbers

Choose a reason for hiding this comment

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

저번 리뷰 때 kotlin delegate 패턴에 대한 단점을 물어봤었죠~

제가 생각하는 delegate 패턴의 단점은 바로 delegate에 대한 대상의 API를 모두 사용할 수 있다라고 생각해요.

일반적인 객체는 객체 캡슐화에 대해서 내부에서는 사용하고 외부에서는 필요한 메서드만 사용할 수 있지만, delegate를 해버리는 순간 의미없는, 사용하지 않는 메서드까지 모두 외부에서 사용할 수 있기 때문에 외부에서 내부적인 부분까지 사용할 수 있어 객체간의 협력이 깨질 수도 있다고 생각해요~

Comment on lines +12 to +17
val lottoTickets: List<LottoTicket> = List(lottoTicketCount.autoTicketCount) {
val autoGenerateStrategy = lottoGenerateStrategyMap.getValue(TicketGenerateType.AUTO)
autoGenerateStrategy.generate()
} + List(lottoTicketCount.manualTicketCount) {
val manualGenerateStrategy = lottoGenerateStrategyMap.getValue(TicketGenerateType.MANUAL)
manualGenerateStrategy.generate()

Choose a reason for hiding this comment

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

👍

@@ -1,18 +1,17 @@
package lotto.domain

import lotto.TicketResult
import lotto.common.LottoTicketPolicy

class StatisticalResultExtractor(

Choose a reason for hiding this comment

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

해당 클래스는 LottoWinningResult 와 합쳐도 되는 부분이라고 생각되네요.

스크린샷 2023-01-01 오후 7 09 58

추가로 해당 부분은 LottoWinningResult 하나만으로도 모두 표현이 가능하지 않을까해요~

현재 의미가 중복되는 클래스가 너무 많아보이네요.

이 부분에 대해서는 충분한 설명이 필요하시다면 DM 부탁드립니다. 같이 이야기해보죠~

class LottoManualGenerateStrategy : LottoGenerateStrategy {
override val ticketGenerateType = TicketGenerateType.MANUAL
override fun generate(): LottoTicket {
val manualLottoNumberStr = readln()

Choose a reason for hiding this comment

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

view에 대한 영역이 아닐까요?

Comment on lines +18 to +29
val lottoWinning = LottoMachine.process(
LottoTicketBundle(lottoTicketCount, listOf(LottoAutoGenerateStrategy(), LottoManualGenerateStrategy())),
WinningBallResult(
WinningBalls(
setOf(
LottoNumber(1), LottoNumber(2), LottoNumber(3),
LottoNumber(4), LottoNumber(5), LottoNumber(6)
)
),
LottoNumber(7)
)
)

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
Development

Successfully merging this pull request may close these issues.

2 participants