Skip to content

Conversation

@sinb57
Copy link

@sinb57 sinb57 commented Mar 6, 2022

안녕하세요 이프입니다!
이전 PR을 Merge 해주셨는데, 아래의 3가지 변경사항이 생겨서 다시 PR 드립니다!

  1. 수동으로 구매할 로또의 개수로 0을 입력할 수 없는 문제 해결
  2. utils 패키지 제거 및 domain 패키지 세분화 진행
  3. BallStorage 클래스 제거 및 Ball 클래스 리팩토링

기존의 캐싱 방식에 대해서 Ball 생성자의 접근제어자가 열려 있기 때문에
equals와 hashcode를 오버라이딩 하지 않겠다는 결론에 도달했습니다.

이부분에 대해 고민해본 결과
Ball 생성자를 열어둔 이유가 BallStorage에서 생성자를 호출하기 위함이라는 것에 주목했고
BallStorageBall과 분리되어야 하는 것에 의구심을 갖게 되었습니다.

결과적으로는, Ball 생성자를 private 접근제어자로 지정함으로써 외부에서 인스턴스를 생성하지 못하도록 차단했고
BallStorage에서 행해지던 캐싱 과정을 Ball 내부로 이동시켰으며 BallStorage를 제거했습니다.


메서드 배치 순서는 스타일의 차이일 뿐, 정답이 없다고 생각합니다.
하지만 그렇다고 해서, 계속 제 방식을 고집하겠다는 것은 당연히 아닙니다.
이 부분은 앞으로 진행될 다양한 미션 과정에서 페어들과 충분히 얘기나눠보고
더 많은 경험을 쌓아가며 스타일을 확립하겠습니다.
메서드 배치 순서에 대해 좋은 얘기를 나눠주셔서 감사합니다!!

Copy link

@choihz choihz 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 +15 to +30
private Ball(final int number) {
BallValidator.validateBallNumber(number);
this.number = number;
}

public static Ball from(final int ballNumber) {
saveBallIfNotExist(ballNumber);
return balls.get(ballNumber);
}

private static void saveBallIfNotExist(final int ballNumber) {
if (balls.containsKey(ballNumber)) {
return;
}
balls.put(ballNumber, new Ball(ballNumber));
}
Copy link

Choose a reason for hiding this comment

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

👍

- [x] `수동으로 구매할 로또의 개수` 입력
- [x] `로또 개수`는 숫자여야 합니다. 아닌 경우, `IllegalArgumentException` 발생
- [x] `로또 개수`양수여야 합니다. 아닌 경우, `IllegalArgumentException` 발생
- [x] `로또 개수`음수가 아니어야 합니다. 아닌 경우, `IllegalArgumentException` 발생
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