Skip to content

Conversation

@ho-jun97
Copy link

리뷰 요청드립니다. 잘 부탁드립니다.

Copy link
Contributor

@javajigi javajigi left a 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);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
index = getNextIndex(line, index);
index = line.move();

이와 같이 이동에 따른 index 결정을 Line이 결정하도록 책임을 부여하면 어떨까?
이와 같이 구현했을 때 테스트 관점에서 어떤 점이 달라지는지 검토해 본다.


// 사다리 게임 생성
LadderGame ladderGame = new LadderGame(players, ladder);
LadderGame ladderGame = new LadderGame(players, ladder, results);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
LadderGame ladderGame = new LadderGame(players, ladder, results);
LadderGame ladderGame = new LadderGame(names, ladder, inputResults);

LadderGame에 부 생성자를 추가해 위와 같이 구현할 수 있도록 지원하면 어떨까?


Assertions.assertThat(results.getResults()).hasSize(4);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

사다리 타기의 복잡도에 비해 단위 테스트가 거의 없다.
이는 객체가 테스트하기 힘든 구조로 설계되어 있다는 반증일 수도 있다.
테스트 가능한 구조로 설계를 개선하고, 가능한 많은 영역에 대해 테스트 추가해 보면 어떨까?

@ho-jun97
Copy link
Author

안녕하세요 피드백 반영했는데요.

 LadderGame에 부 생성자를 추가해 위와 같이 구현할 수 있도록 지원하면 어떨까? 

라는 피드백에 진행하려했지만 ladder를 만드는 과정에서 결국에 player의 size가 필요해서 고민을 하다가
정적메소드를 사용해서players, result, ladder를 만들어서 새로운 객체를 만들고, 생성자를 private를 만들어서 of를 통하게 만들도록 했습니다.

ladder를 만들 때 player.size를 받아야하는게 설계가 잘못된거 싶기도하면서 일단 정적메소드를 만들어서 리뷰요청드립니다.

리뷰 잘 부탁드립니다.

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