Repository navigation
Step1 - #67
Step1#67
Conversation
| FrameResults results = new FrameResults(); | ||
| Frames frames = new Frames(); | ||
| while (!frames.isFinish()) { | ||
| doGame(player, results, frames); |
There was a problem hiding this comment.
FrameResults를 지금과 같이 구현하는 것과 매번 투구를 할 때마다 생성하는 구조 중 어느 것이 더 나을까?
매번 생성하면 OutputView.printGameResult(player.frames.getFrameResults());와 같이 구현하는 구조가 될텐데..
성능과 코드의 복잡도, 테스트 용이성 등 각각의 장단점에 대해 고민해 보면 좋겠다.
There was a problem hiding this comment.
Player가 FrameResults를 가지고 있도록 수정했습니다.
List가 매번 생성되는 것보다 Player가 FrameResults를 가지고 있으면서 해당 프레임 번째에 FrameResult가 있는지 체크하고 있다면 투구 결과를 add 하는 방식이 메모리 아끼는 것이나 Player의 FrameResults를 불시에 사용하거나 검증할 때 좋다고 생각합니다.
|
|
||
| public String getName() { | ||
| return name.getName(); | ||
| } |
There was a problem hiding this comment.
Player와 Frames간의 객체 관계는 어떻게 될까?
현재와 같이 분리해서 구현하는 경우와 Player가 Frames와 의존 관계를 가지도록 구현하는 경우 중 어느 것이 더 나은 설계일까?
| return scores.stream().mapToInt(scoreInstance -> scoreInstance.score).sum() == MAX; | ||
| } | ||
|
|
||
| public boolean isOverRecord(List<Score> scores) { |
There was a problem hiding this comment.
isScoreLimit(), isOverRecord() 메소드를 분리한 이유는?
둘 다 필요한가?
There was a problem hiding this comment.
isOverRecord는 Scores에 총 2번 기록이 되는데 이전에 저장되어있는 Score에 지금 몇점의 점수를 추가하려고 하는데 최대 10점(정규 투구)을 넘었을 경우 입력 예외처리를 하기위해서 만들어진 것입니다. 메소드를 사용할 때 이전에 저장되어있다는 조건을 달아주지않아서 의도가 명확하지않았던 것 같습니다.
isScoreLimit은 프레임의 상태를 설정하기 전에 Scores에 점수가 10점인지 아닌지를 물어볼 때 사용하려고 구현했습니다.
두 메소드의 차이는 10점이냐 10점을 넘어가냐의 의미적인 차이와 평가를 할 때 주어지는 조건값이 달라 각각 만들어놓았습니다.
| return convertScore(score); | ||
| } | ||
| scores.addScore(score); | ||
| status = FrameStatus.changeStatus(scores); |
There was a problem hiding this comment.
현재 status가 있고, 이 status가 다음 status를 생성하는 구조로 구현하면 어떨까?
| package domain.frame.result; | ||
|
|
||
| public enum ScoreMessage { | ||
| TEN("X"), |
There was a problem hiding this comment.
SPARE("/")는 없나?
STRIKE, SPARE, ZERO 구조가 되어야 하는 것 아닌가?
| } | ||
|
|
||
| public static boolean isStrike(FrameStatus status) { | ||
| return status instanceof Strike; |
There was a problem hiding this comment.
instanceof를 쓰지 않고 구현할 수 있는 방법을 고민해 본다.
고민하다 방법을 찾지 못하면 skip
|
|
||
| @Override | ||
| public String convertScore(int score) { | ||
| return "/"; |
| public static boolean isValidEnglishName(String name) { | ||
| char[] convertName = name.toCharArray(); | ||
| for (char ch : convertName) { | ||
| if ((ch < 'A' || ch > 'Z') && (ch < 'a' || ch > 'z')) { |
There was a problem hiding this comment.
확실하지는 않은데 String에 이를 위해 제공해 주는 메소드가 있지 않나?
나도 확실치가 않네. 찾아보니 Character에 있는 것 같네.
…tanceof 대체), Miss ScoreMessage 누락부분 수정, status에 요청해서 변경된 status 받도록 수정
구현한 것