Skip to content

[로또] 김연서 미션 제출합니다.#8

Open
daeGULLL wants to merge 12 commits intoJava-JavaScript-Language-Stuty:mainfrom
2025JavaGroupStudy:yeunsuh
Open

[로또] 김연서 미션 제출합니다.#8
daeGULLL wants to merge 12 commits intoJava-JavaScript-Language-Stuty:mainfrom
2025JavaGroupStudy:yeunsuh

Conversation

@daeGULLL
Copy link
Copy Markdown

@daeGULLL daeGULLL commented Feb 27, 2025

왜 이전 제출부터 다른 분 커밋을 referenced했다고 뜨는지 했더니만... #붙이고 숫자 붙이면 그리되는 모양이드라구요 README.md의 기능 목록 몇 번과 연관되어있다는걸 보여주기 위해 저걸 붙이고 커밋했었는데 이제는 그러면 안되겠습니다ㅎㅎ;; 메일 가신분들 죄송해요 ㅜㅜ

1. 신경써서 구현한 부분

  1. Validator의 Util 속성
    util에 속하는만큼 재사용성을 갖게끔 신경 써 만들었습니다.

  2. 에러 메세지
    enum 2개를 통해 예외 대분류와 소분류(상세내용)을 표현해보았고, 예외 대분류는 controller에서 최대한 부여할수 있게 해봤습니다.

  3. 옵저버 패턴 미사용
    이제 옵저버 패턴이 손에 익어 컨트롤러가 뷰와 모델을 매개하는 방법으로 대체해봤습니다.

  4. for문보다는 stream 또는 forEach 일관적 사용
    어쩔수 없는 경우 빼고는 최대한 일관적으로 하고자 했습니다

2. 피드백이 필요한 부분

가독성이나 책임 분리등 되는것들 주시면 감사할 것 같습니다..ㅎㅎ
최대한 15줄 내로 모든걸 짜려고 했는데 실수로 미체크한 부분 있으면 지적해주세요

3. 내가 고려한 예외

중복 금지, 범위 확인, 로또 번호 갯수, 비용 관련 예외, 당첨 번호 관련, 보너스 번호 관련

보너스 공 수랑 당첨 공들 안겹치게함.
view에 콘솔 출력을 위임안하고 에러 catch에서 system.out.println을 바로 호출하게 했다는것을 발견
Copy link
Copy Markdown
Contributor

@moongua404 moongua404 left a comment

Choose a reason for hiding this comment

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

3주차 미션 구현하시느라 너무 수고 많으셨습니다!! 이전 스터디에서 스터디원끼리 코드에서도 각자의 색깔이 묻는다고 얘기했었는데, 다른 사람들보다 더 강한 색채를 가지고 있는 것 같아요ㅋㅋㅋ 많이 배우고 갑니다ㅎㅎ


public boolean buyStep() {
try {
Player player = setLottoMoney();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

서비스가 있음에도 모델을 컨트롤러 내부에 두신 이유가 있나요?
제 생각에는 컨트롤러 내부에 있는 로직들은 서비스에 분리하는게 컨트롤러에 부담을 줄이고 관심사를 분리하는데 용이할 것 같습니다

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

구현할 당시에는 로또 서비스는 로또만 다루게 해야지~~ 단순히 생각했다가 최종 제출 때 살짝 아차한 부분이긴 합니다ㅋㅋ 아무래도 서비스가 있는한 다른 모델들을 서비스 내부에서 다루게하는게 좋겠죠?

return (T) Integer.valueOf(inputLine);
}
throw new IllegalArgumentException(DetailErrorMessage.DEV_TYPE_WRONG.getMessage());
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

반환형을 제네릭으로 두어 알아서 타입을 추론해 여러 맥락에 적용될 수 있는 코드 맞나요? 저도 4주차 미션에 써먹어야겠네요ㅋㅋㅋㅋ
하지만 검증을 담당하는 메서드에서 강제적 형변환을 범용적으로 허용한다면 안정성이 떨어질 수 있을 것 같아요
가령 isSingleInputType("20250228", dateType.NUMBER로 하면... 컴파일 타임에는 에러를 안띄우지만 런타임에서 CastException을 발생시킬겁니다.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

어라라 그러네요?? 저걸 생각못했네 반영해 수정하겠읍니다~~

import java.util.stream.IntStream;
import lotto.util.DetailErrorMessage;

public class Player {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

로또에서 Player라는 객체를 만드신 맥락이 궁금해요! 문제를 어떻게 해석하시고 객체를 어떻게 정의하셨나요??

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

로또를 사서 여러장을 가지고 있다가 추첨 결과에 따라 그 사람이 상품을 탈테니 그걸 고려하구 플레이어 모델을 만들었습니당~~

Player setLottoMoney() {
try {
String inputLine = lottoView.inputPurchaseMoney();
return Player.setLottoMoney(Validator.isSingleInputType(inputLine, dataType.NUMBER));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Validator가 값을 다시 뱉으니 가독성이 떨어지는 것 같아요!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

글쿤요 따로 분리하겠슴다


public List<Integer> getNumbers() {
return numbers;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

전반적으로 모델의 역할이 약한 것 같아요...!
List가 private final으로만 선언되어서 배열 전체를 반환할 경우 외부에서 배열 내부의 값을 수정하는 문제가 발생할 수 있을 것 같아요
또 배열을 만들어서 내뱉는 역할만 한다면 모델이라고 보기 어려운 측면이 있을 것 같아요

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

모델에 대해 전에 공부햇을때 dto에 가까운 넘도 모델이라구 해서 걍 이놈도 모델처리해버렸습니당 또 배열 반환 수정이 문제군요..오호.. 그럼 얕은복사한 배열을 돌려쥬면 문제가 안되겠죠??

Copy link
Copy Markdown
Contributor

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