-
Notifications
You must be signed in to change notification settings - Fork 14
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
1단계 미션 제출합니다. #4
base: uijin-j
Are you sure you want to change the base?
Conversation
- Java17, Junit5, AssertJ 의존성 추가 - .gitignore 업데이트
전반적인 구조 설계
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셧습니다.
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class CommandFactory { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이건 Command에 넣으면 되지 않을까요?
혹시 따로 Factory를 만드신 이유가 있나요?
|
||
public class CommandFactory { | ||
|
||
private final Map<String, Command> commandMap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Map이라는 단어보단 복수형으로 쓰는게 좋을거 같습니다.
Map.of( | ||
"1", new PlayGameCommand( | ||
new ConsoleBaseballGame( | ||
inputView, outputView, new RandomBallNumbersGenerator())), | ||
"9", new ExitApplicationCommand(this) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 이 부분을 따로 분리하면 어떨까요?
- 차후 여기서 1과 9에 대해서 알기가 어려운거 같아요. 상수화를 하면 어떨까요?
private BallNumbers targetNumbers; | ||
private boolean isRunning; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ConsoleBaseBallGame에서 상태를 가지고 있는게 이상한거 같아요.
ConsoleBaseBallGame은 어떤 역할을 하는건가요?
checkArgument( | ||
number >= MIN_BALL_NUMBER && number <= MAX_BALL_NUMBER, | ||
"BallNumber은 " + MIN_BALL_NUMBER + "~" + MAX_BALL_NUMBER + "사이의 숫자여야 합니다." | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
다른 생성자 혹은 다른 정적 팩터리 메서드를 만든다면 이 부분은 또 작성해야하지 않나요?
이럴땐 생성자에서 차라리 하면 어떨까요?
public final class Validator { | ||
|
||
private Validator() { | ||
// 유틸리티 클래스 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
주석은 제거해도 되지 않을까요?
// 유틸리티 클래스 | ||
} | ||
|
||
public static void checkArgument(boolean expression, String message) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 이건 좋네요 👍
BallNumber created = BallNumber.of(number); | ||
|
||
// then | ||
assertNotNull(created); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertJ를 적극적으로 활용해보면 어떨까요?
.withMessage("야구 숫자는 1~9사이의 서로 다른 3자리 숫자여야 합니다."); | ||
} | ||
|
||
@DisplayName("BallNumbers가 가지고 있는 숫자를 추측하여, 추측 결과를 확인한다. (Case. 3스트라이크)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이런경우 ParameterziedTest를 사용해볼수 있지 않을까요?
BallNumbers generated = randomBallNumbersGenerator.generate(); | ||
|
||
// then | ||
assertThat(generated).isNotNull(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이게 과연 랜덤으로 생성된 값을 반환했다고 볼수 있을까요?
No description provided.