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

[로또 게임 과제] 정건우 제출합니다 #17

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

jgw1202
Copy link

@jgw1202 jgw1202 commented Jul 18, 2024

No description provided.

Copy link
Collaborator

@genius00hwan genius00hwan left a comment

Choose a reason for hiding this comment

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

전반적으로 mvc를 적용하려는 노력이 보였습니다. 그리고 인스턴스를 관리하는 객체를 만든것은 좋은생각입니다. 다만 비즈니스 로직을 controller에서 처리하려고 노력해보는게 어떨까요?

import lotto.view.ConsoleInput;
import lotto.view.LottoGame;

public class InstanceManager {
Copy link
Collaborator

Choose a reason for hiding this comment

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

마치 스프링 컨테이너 역할을 하는 클래스를 만들었군요 좋습니다.

import java.util.ArrayList;
import java.util.List;

public class LottoMachineModel {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Model은 데이터를 담는 객체를 말합니다. model 보다는 domain에 가까워 보입니다.

import java.util.Set;
import java.util.HashSet;

public class WinningResultModel {
Copy link
Collaborator

Choose a reason for hiding this comment

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

model이 비즈니스 로직을 수행하네요. 물론 그러지 말라는 법은 없지만 mvc 패턴에서는 컨트롤러가 사용자로부터의 입력에 대한 응답으로 모델 및/또는 뷰를 업데이트하는 로직을 포함합니다.

import java.util.List;
import java.util.Set;

public class LottoGame {
Copy link
Collaborator

Choose a reason for hiding this comment

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

전반적인 흐름을 관리하는 것으로 보아 view보단 controller가 좀더 어울리네요

import java.util.HashSet;
import java.util.Set;

public class ConsoleInput {
Copy link
Collaborator

Choose a reason for hiding this comment

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

입력에서 유효성 검증을 대부분 처리하네요. 물론 그러지 말라는 법은 없지만 유효성 검증도 비즈니스 로직에 포함되는 경우가 많습니다.

String input = Console.readLine();
int purchaseAmount;
try {
purchaseAmount = Integer.parseInt(input);
Copy link
Collaborator

Choose a reason for hiding this comment

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

예를 들면 정수가 아닌 입력은 잘못된 입력형식이라고 생각할 수 있어 입력단에서 처리하는게 나쁘지 않아보입니다.

} catch (NumberFormatException e) {
throw new IllegalArgumentException("구입 금액은 숫자여야 합니다.");
}
if (purchaseAmount % 1000 != 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

다만 구매 금액이 1000원단위가 아닌것은 잘못된 입력보다는 잘못된 "구매금액"아닐까요? 그렇다면 구매금액 객체를 관리하는 비즈니스 로직단에서 처리하는게 어떨까요?

@genius00hwan
Copy link
Collaborator

그리고 커밋 컨벤션 지킨건 건우님밖에 없네요 짱짱!!

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