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

πŸš€ 3단계 - 둜또(2λ“±) #3559

Open
wants to merge 8 commits into
base: h3yon
Choose a base branch
from

Conversation

h3yon
Copy link

@h3yon h3yon commented Dec 11, 2023

μ•ˆλ…•ν•˜μ„Έμš” λ¦¬λ·°μ–΄λ‹˜!
2단계 λ•Œ 남겨주신 리뷰둜 μ½”λ“œ μž‘μ„±ν•˜λ‹ˆ 더 쒋은 μ½”λ“œκ°€ 된 것 κ°™μŠ΅λ‹ˆλ‹€.
μ΄λ²ˆμ—λ„ PR 리뷰 및 승인 μš”μ²­λ“œλ¦½λ‹ˆλ‹€.
κ°μ‚¬ν•©λ‹ˆλ‹€!

Copy link

@catsbi catsbi left a comment

Choose a reason for hiding this comment

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

μ•ˆλ…•ν•˜μ„Έμš” ν¬μœ€λ‹˜ μ–΄λŠλ§ 3단계 λ―Έμ…˜μ΄λ„€μš”.
λͺ‡ 가지 ν”Όλ“œλ°± λ‚¨κ²¨λ“œλ ΈμœΌλ‹ˆ 확인 ν›„ λ‹€μ‹œ λ¦¬λ·°μš”μ²­ λΆ€νƒλ“œλ¦½λ‹ˆλ‹€!

import static auto.application.MatchedAmount.findByCount;

public class MatchLottoService {
private static final Map<MatchedAmount, Integer> matchedCountMap = new HashMap<>();// = MatchedAmount.getMatchedCountMap();
Copy link

Choose a reason for hiding this comment

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

  1. μ„œλΉ„μŠ€ 계측이면 μ΅œλŒ€ν•œ λ¬΄μƒνƒœ(stateless)계측 섀계λ₯Ό 지양해보면 μ–΄λ–¨κΉŒμš”? μž¬μ‚¬μš©μ„± μ΄μŠˆκ°€ μžˆμœΌλ‹ˆκΉŒμš”
  2. 이 경우 Enumνƒ€μž…μ„ key둜 μ‚¬μš©ν•œλ‹€λ©΄ HashMap보닀 EnumMap을 μ‚¬μš©ν•˜λŠ”κ±΄ μ–΄λ–¨κΉŒμš”

int bonusBallNumber) {
List<Integer> copyLottoNumbers = new ArrayList<>(lottoNumbers);
copyLottoNumbers.removeAll(winningNumbersLastWeek);
return copyLottoNumbers.contains(bonusBallNumber);
Copy link

Choose a reason for hiding this comment

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

bonusNumberκ°€ μ²˜μŒλΆ€ν„° 당첨 λ²ˆν˜Έμ™€ μ€‘λ³΅λ˜μ§€ μ•ŠλŠ” 번호라면, removeAll을 μˆ˜ν–‰ν•˜λ©° 맀번 번호λ₯Ό μ œκ±°ν•  ν•„μš”κ°€ 없을 것 κ°™λ„€μš”

Comment on lines +51 to +58
int matchedCountSum = (int) lottoNumbers.stream()
.filter(winningNumbersLastWeek::contains)
.count();
MatchedAmount matchedAmount = findByCount(matchedCountSum, isMatchedBonusNumber);
if (matchedAmount.getCount() > 0) {
matchedCountMap.put(matchedAmount, matchedCountMap.get(matchedAmount) + 1);
}
}
Copy link

Choose a reason for hiding this comment

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

Stream API의 groupByλ₯Ό ν™œμš©ν•œλ‹€λ©΄ μ’€ 더 κ°„λ‹¨ν•˜κ²Œλ„ κ°€λŠ₯ν•œλ°, 고민해보면 쒋을 것 κ°™μŠ΅λ‹ˆλ‹€.

@@ -28,7 +29,10 @@ public enum MatchedAmount {
this.amount = amount;
}

public static MatchedAmount findByCount(int count) {
public static MatchedAmount findByCount(int count, boolean isMatchedBonus) { // findByNumberWithMatchedBonus
if (count == FIVE.getCount()) {
Copy link

Choose a reason for hiding this comment

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

μ§€κΈˆμ€ λ³΄λ„ˆμŠ€ 번호 맀칭 μ—¬λΆ€λ§Œ 가지고 λ“±κΈ‰ νŒλ‹¨μ΄λ˜μ—ˆμ§€λ§Œ, 이런 쑰건듀이 κ³„μ†ν•΄μ„œ μΆ”κ°€λœλ‹€λ©΄ ν•΄λ‹Ή λ‘œμ§μ— κ³„μ†ν•΄μ„œ νŒλ‹¨ 뢄기문이 μΆ”κ°€λ˜μ•Όν• κΉŒμš”? λžŒλ‹€ν‘œν˜„μ‹μ„ ν™œμš©ν•΄μ„œ μ—΄κ±°νƒ€μž…μ˜ 각 μΈμŠ€ν„΄μŠ€κ°€ μžμ‹ μ΄ λ§žλŠ”μ§€ νŒŒμ•…ν•  수 μžˆλ„λ‘ ν•  수 μ—†μ„κΉŒμš”?

Comment on lines +12 to +13
private static final int MAXIMUM_LOTTO_NUMBER_SIZE = 6;
private final List<Integer> numbers;
Copy link

Choose a reason for hiding this comment

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

  1. μƒμˆ˜μ™€ λ³€μˆ˜κ°„μ˜ κ°œν–‰μœΌλ‘œ 가독성을 λ†’ν˜€λ³΄λ©΄ 쒋을 것 κ°™μŠ΅λ‹ˆλ‹€.
  2. collection νƒ€μž…μ€ ν•„λ“œμ΄ˆκΈ°ν™”λ„ ꢌμž₯λ“œλ¦½λ‹ˆλ‹€.

Comment on lines +32 to +34
List<Integer> numbers = IntStream.range(LOTTO_MIN_NUMBER, LOTTO_MAX_NUMBER + 1)
.boxed()
.collect(Collectors.toList());
Copy link

Choose a reason for hiding this comment

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

  • 맀번 둜또번호λ₯Ό 1~45κΉŒμ§€ μƒμ„±ν•΄μ„œ μ»¬λ ‰μ…˜μ„ λ§Œλ“€κ³  , μ„žκ³ , 6개λ₯Ό κΊΌλ‚΄μ„œ μƒˆλ‘œμš΄ 리슀트λ₯Ό λ§Œλ“€μ–΄μ•Όν• κΉŒμš”?
  • 일급 객체λ₯Ό ν™œμš©ν•΄λ³΄λ©΄ μ–΄λ–¨κΉŒμš”?(이전 ν”Όλ“œλ°± 반볡)
  • 캐싱을 ν™œμš©ν•΄λ³΄λ©΄ μ–΄λ–¨κΉŒμš”?

import java.util.Scanner;
import java.util.stream.Collectors;

import static auto.domain.Lotto.LOTTO_MAX_NUMBER;
import static auto.domain.Lotto.LOTTO_MIN_NUMBER;

public class InputView {
Copy link

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