Skip to content

Step1 - #67

Merged
javajigi merged 16 commits into
code-squad:imjinbrofrom
imjinbro:step1
Apr 9, 2018
Merged

javajigi merged 16 commits into
code-squad:imjinbrofrom
imjinbro:step1

Conversation

@imjinbro

@imjinbro imjinbro commented Apr 6, 2018 •

Copy link
Copy Markdown

구현한 것

  1. 구조 생성
  2. 플레이어 이름 입력 - 플레이어 관리 클래스 생성
  3. 점수 입력 받기 프로세스 구현
  4. 입력 받은 점수 관리 클래스 생성 - Scores, Score
  5. 프레임 종류 나누기 - Normal/LastFrame
  6. 프레임 상태 부여 - Strike, Spare, Miss, Ing(프레임 상태에 따라 결과 만들기)
  7. 볼링 결과 출력

@javajigi javajigi left a comment

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.

전체적으로 깔끔하게 구현 잘 했다. 👍
생각해 봤으면 하는 주제 포함해 몇 개 피드백 남겨본다.

Comment thread src/main/java/BowlingMain.java Outdated
FrameResults results = new FrameResults();
Frames frames = new Frames();
while (!frames.isFinish()) {
doGame(player, results, frames);

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.

FrameResults를 지금과 같이 구현하는 것과 매번 투구를 할 때마다 생성하는 구조 중 어느 것이 더 나을까?
매번 생성하면 OutputView.printGameResult(player.frames.getFrameResults());와 같이 구현하는 구조가 될텐데..
성능과 코드의 복잡도, 테스트 용이성 등 각각의 장단점에 대해 고민해 보면 좋겠다.

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가 FrameResults를 가지고 있도록 수정했습니다.
List가 매번 생성되는 것보다 Player가 FrameResults를 가지고 있으면서 해당 프레임 번째에 FrameResult가 있는지 체크하고 있다면 투구 결과를 add 하는 방식이 메모리 아끼는 것이나 Player의 FrameResults를 불시에 사용하거나 검증할 때 좋다고 생각합니다.


public String getName() {
return name.getName();
}

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와 Frames간의 객체 관계는 어떻게 될까?
현재와 같이 분리해서 구현하는 경우와 Player가 Frames와 의존 관계를 가지도록 구현하는 경우 중 어느 것이 더 나은 설계일까?

return scores.stream().mapToInt(scoreInstance -> scoreInstance.score).sum() == MAX;
}

public boolean isOverRecord(List<Score> scores) {

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.

isScoreLimit(), isOverRecord() 메소드를 분리한 이유는?
둘 다 필요한가?

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.

isOverRecord는 Scores에 총 2번 기록이 되는데 이전에 저장되어있는 Score에 지금 몇점의 점수를 추가하려고 하는데 최대 10점(정규 투구)을 넘었을 경우 입력 예외처리를 하기위해서 만들어진 것입니다. 메소드를 사용할 때 이전에 저장되어있다는 조건을 달아주지않아서 의도가 명확하지않았던 것 같습니다.

isScoreLimit은 프레임의 상태를 설정하기 전에 Scores에 점수가 10점인지 아닌지를 물어볼 때 사용하려고 구현했습니다.

두 메소드의 차이는 10점이냐 10점을 넘어가냐의 의미적인 차이와 평가를 할 때 주어지는 조건값이 달라 각각 만들어놓았습니다.

return convertScore(score);
}
scores.addScore(score);
status = FrameStatus.changeStatus(scores);

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.

현재 status가 있고, 이 status가 다음 status를 생성하는 구조로 구현하면 어떨까?

package domain.frame.result;

public enum ScoreMessage {
TEN("X"),

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.

SPARE("/")는 없나?
STRIKE, SPARE, ZERO 구조가 되어야 하는 것 아닌가?

}

public static boolean isStrike(FrameStatus status) {
return status instanceof Strike;

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.

instanceof를 쓰지 않고 구현할 수 있는 방법을 고민해 본다.
고민하다 방법을 찾지 못하면 skip


@Override
public String convertScore(int score) {
return "/";

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.

??
왜 이놈만..

public static boolean isValidEnglishName(String name) {
char[] convertName = name.toCharArray();
for (char ch : convertName) {
if ((ch < 'A' || ch > 'Z') && (ch < 'a' || ch > 'z')) {

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.

확실하지는 않은데 String에 이를 위해 제공해 주는 메소드가 있지 않나?
나도 확실치가 않네. 찾아보니 Character에 있는 것 같네.

imjinbro added 2 commits April 9, 2018 14:55
…tanceof 대체), Miss ScoreMessage 누락부분 수정, status에 요청해서 변경된 status 받도록 수정
@javajigi
javajigi merged commit 2ca64d9 into code-squad:imjinbro Apr 9, 2018
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