-
Notifications
You must be signed in to change notification settings - Fork 744
Step3-사디리(게임 실행) #2439
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
base: ho-jun97
Are you sure you want to change the base?
Step3-사디리(게임 실행) #2439
Conversation
javajigi
left a comment
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.
3단계 진행하느라 수고했음다. 👍
단, 단위 테스트 수가 너무 적은데요.
사다리 타기 로직의 복잡도가 있는 만큼 단위 테스트 추가가 가능한 구조로 객체 설계를 개선해 보면 어떨까요?
| public int move(int startIndex){ | ||
| int index = startIndex; | ||
| for(Line line: lines) { | ||
| index = getNextIndex(line, index); |
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.
| index = getNextIndex(line, index); | |
| index = line.move(); |
이와 같이 이동에 따른 index 결정을 Line이 결정하도록 책임을 부여하면 어떨까?
이와 같이 구현했을 때 테스트 관점에서 어떤 점이 달라지는지 검토해 본다.
|
|
||
| // 사다리 게임 생성 | ||
| LadderGame ladderGame = new LadderGame(players, ladder); | ||
| LadderGame ladderGame = new LadderGame(players, ladder, results); |
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.
| LadderGame ladderGame = new LadderGame(players, ladder, results); | |
| LadderGame ladderGame = new LadderGame(names, ladder, inputResults); |
LadderGame에 부 생성자를 추가해 위와 같이 구현할 수 있도록 지원하면 어떨까?
|
|
||
| Assertions.assertThat(results.getResults()).hasSize(4); | ||
| } | ||
| } |
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.
사다리 타기의 복잡도에 비해 단위 테스트가 거의 없다.
이는 객체가 테스트하기 힘든 구조로 설계되어 있다는 반증일 수도 있다.
테스트 가능한 구조로 설계를 개선하고, 가능한 많은 영역에 대해 테스트 추가해 보면 어떨까?
|
안녕하세요 피드백 반영했는데요. 라는 피드백에 진행하려했지만 ladder를 만드는 과정에서 결국에 player의 size가 필요해서 고민을 하다가 ladder를 만들 때 player.size를 받아야하는게 설계가 잘못된거 싶기도하면서 일단 정적메소드를 만들어서 리뷰요청드립니다. 리뷰 잘 부탁드립니다. |
리뷰 요청드립니다. 잘 부탁드립니다.