-
Notifications
You must be signed in to change notification settings - Fork 745
[사다리타기 - FP, OOP] 2단계 사다리(생성) #1414
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
Conversation
Optional 적용 - Lambda 객체 메서드 전부 Lambda 적용
플레이어 이름은 최대 5글자만 가능하다 - Player 객체 추가 - 플레이어 이름 5글자 이상 예외처리
입력된 플레이어 이름들을 ,(콤마) 구분한다 - Players 객체 추가 - Players 팩토리 메서드 추가
사다리 가로 라인은 겹치지 않도록 한다. - Line 객체 구현 - Ladder 객체 구현
사다리 게임 실행 구현 - 입력 view 구현 - 출력 view 구현 - 입력 사다리 높이 값 원시값 포장 객체로 구현
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.
정재님 사다리 생성 2단계 미션 잘 구현해주셨습니다. 👏👏
전체적으로 설계가 깔끔해서 가독성이 좋습니다 😄
크게 문제될 부분은 없으나 테스트가 좀 더 풍부하고, 경계값등에 대한 테스트도 작성되면 더 좋을 것 같네요! 그 밖에 피드백이 필요한 부분들 코멘트 남겨드렸으니 확인 후 다음 단계 진행하면서 같이 반영해보면 좋을 것 같습니다. 고생하셨고 다음 단계 진행하시죠!
@@ -0,0 +1,8 @@ | |||
package nextstep.fp; | |||
|
|||
@FunctionalInterface |
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.
오 FunctionalInterface 애노테이션 활용을 잘 해주셨습니다 👍
Players players = new Players(Players.create(InputView.playerNames())); | ||
Height height = new Height(InputView.ladderHeight()); | ||
Ladder ladder = new Ladder(height.height(), players.count()); | ||
ResultView.print(players); | ||
ResultView.print(ladder); |
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.
적절한 개행은 가독성을 높힐 수 있습니다 👍
if (height < 1) { | ||
throw new IllegalArgumentException("사다리 높이는 1보다 작을 수 없습니다."); |
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.
매직 리터럴과 매직 넘버는 분리해주시는게 어떨까요?!
|
||
public class Ladder { | ||
|
||
private final List<Line> lines; |
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는 lines만을 관리하기위한 도메인인지 고민해 볼 필요가 있어요.
Ladder에서 lines에 대한 인덱스 관리등을 하는 책임이 적절한지 아닌지에 따라 lines를 이대로 둘지 Lines라는 일급 컬렉션을 분리할지 결정할 수 있거든요. 한 번 고민해볼까요?
public Ladder(int height, int countOfPerson) { | ||
this(lines(height, countOfPerson)); | ||
} |
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.
이 경우 점진적 생성자 패턴보다는 그냥 정적 팩토리 메서드 패턴을 사용해도 되었을 것 같네요 😄
@Test | ||
@DisplayName("사다리 높이 생성") | ||
void create() { | ||
assertThat(new Height("5")).isEqualTo(new Height(5)); | ||
} |
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.
테스트를 할 때는 무의미한 하나의 값으로 성공하기만 하는 테스트를 작성하는것은 해당 기능이 틀리지 않음을 증명하기 힘듭니다. 경계값테스트를 통해 좀 더 의미있는 테스트를 구현해보는건 어떨까요?
} | ||
|
||
@Test | ||
@DisplayName("사다리 높이 1보다 작을 경우 예외") |
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.
음수일 경우에 대해서도 작성해보는건 어떨까요?
@Test | ||
void create() { | ||
Line line = new Line(List.of(true, false, true)); | ||
assertThat(line).isEqualTo(new Line(List.of(true, false, true))); | ||
} |
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.
무엇을 테스트하는지 작성하면 좋지 않을까요?
} | ||
|
||
@Test | ||
@DisplayName("플레이어 이름 최대 5글자 이상 예외 처리") |
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.
1글자 미만의 플레이어 이름도 테스트하면 어떨까요?
public class PlayersTest { | ||
|
||
@Test | ||
@DisplayName("입력된 플레이어 이름들을 ,(콤마) 구분하여 플레이어 생성") |
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.
콤마 사이에 띄어쓰기등을 처리해주는 로직도 테스트가 되면 어떨까요?
안녕하세요!
[사다리타기 - FP, OOP] 2단계 사다리(생성) 구현 완료하여 PR 드립니다!
1단계 피드백 내용도 작업하였습니다!
이번에도 리뷰 잘 부탁드릴게요!! :)
감사합니다!