Skip to content

Conversation

@cyLee1111
Copy link

@cyLee1111 cyLee1111 commented Sep 27, 2024

✨사다리 출력, 사다리 자동 생성 기능 추가

  • 배열로 position value 받아오고, printRows로 사다리 출력
  • AutoLadderCreator의 drawLine으로 자동 그리기 기능 추가

♻️ 객체지향성 추가

  • LadderCreator interface를 만들었고, AutoLadderCreator와 DefaultLadderCreator에서 구현
  • drawLine의 두 가지 방식을 나누고(default, auto) 해당되지 않는 방식으로 접근했을 때의 예외처리 추가
  • AutoLadderCreator의 drawLine을 리팩토링 (private method로 중복 자리 접근/이웃 사다리 그리기/상세한 조건 분리)
  • printRows 내부에서 printRow로 따로 method를 뺌

코드리뷰 부탁합니다..! 🥹

Copy link

@twkwon0417 twkwon0417 left a comment

Choose a reason for hiding this comment

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

꼼꼼히 잘 진행 하셨습니다. 💯
객체 지향적으로 짜시려 한게 느껴져서 코드 리뷰 하면서 저도 재밌었습니다 🥇

Comment on lines +17 to +19
void drawLine(Position row, Position col);

void drawLine();

Choose a reason for hiding this comment

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

row, col을 인자로 갖는 drawLine은 Default에서만 쓰이고 인자가 없는 drawLine은 Auto에서만 쓰이는데 abstract method로 선언힌 이유가 있을 까요?

Position col = Position.from(randomInt % (ladderSize.getNumberOfPerson() - 1));

try {
rows[row.getValue()].drawLine(col);

Choose a reason for hiding this comment

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

DefaultLadderCreator에서 drawLine 메서드와 같은 로직 인거 같아요! 재사용할수 있는 방법이 있지 않을까요?

Choose a reason for hiding this comment

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

AutoLadderCreator가 사다리를 잘 생성했는지 unit testing하기 힘들어 보여요. 책임을 분리 하면 테스트를 더 쉽게 작성 할수 있을 것 같습니다!

Choose a reason for hiding this comment

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

Enum으로 관리 하다니 멋져요!

Comment on lines +10 to +12
public LadderGame(LadderCreator ladderCreator) {
this.ladderCreator = ladderCreator;
}

Choose a reason for hiding this comment

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

DI 잘 활용하셨습니다!!

Choose a reason for hiding this comment

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

출력의 책임을 LadderRunner에 위임한게 인상적이네요

return position.getValue();
}

private void printRows(int moveX, int moveY) {

Choose a reason for hiding this comment

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

position대신 int를 쓰셨는데, 이유가 뭔가요?

Comment on lines +30 to +40
public void setRightNode() {
direction = RIGHT;
}

public void setLeftNode() {
direction = LEFT;
}

public boolean isAlreadySetDirection() {
return !isNone();
}

Choose a reason for hiding this comment

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

Node의 값이 변경될때, 새로운 node를 생성하는 방식으로 처리해도 될거 같은데, setter을 사용한 특별한 이유가 있나요?

Comment on lines +52 to +68
//given
Position position = Position.from(0);

//then
assertThat(ladderGame.run(position)).isEqualTo(2);

//given
position = Position.from(1);

//then
assertThat(ladderGame.run(position)).isEqualTo(1);

//given
position = Position.from(2);

//then
assertThat(ladderGame.run(position)).isEqualTo(0);

Choose a reason for hiding this comment

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

@ParmeterizedTest, @CsvSource 등 test관련 annotation에 대해 더 알아보면 좋을 거 같습니다 👍

Choose a reason for hiding this comment

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

예외 상황도 빠짐 없이 테스트 하셨군요 💯

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.

3 participants