-
Notifications
You must be signed in to change notification settings - Fork 26
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
2주차 미션 / 서버 1조 김지현 #49
base: main
Are you sure you want to change the base?
Conversation
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.
구현하느라 정말 고생하셨습니다! 구체적인 테스트 코드랑 객체지향적으로 코드 짜려는것이 인상깊습니다!
|
||
private final int number; | ||
|
||
public GreaterThanOne(int number) { |
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.
정적 팩터리 메서드인 from()으로 객체를 반환하니 생성자는 private으로 설정해도 좋아보이네요!
@@ -0,0 +1,29 @@ | |||
package ladder; | |||
|
|||
public class GreaterThanOne { |
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.
GreaterThanOne 클래스로 빼신 이유가 있을까요?
private final Row[] rows; | ||
|
||
public LadderCreator(GreaterThanOne numberOfRow, GreaterThanOne numberOfPerson) { | ||
rows = new Row[numberOfRow.getNumber()]; |
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.
로우를 불러 올때 생성자보다 따로 매개변수를 가진 정적 팩터리 메서드를 생성하여 불러오는게 좋겠네요!
class LadderGameTest { | ||
|
||
@Test | ||
void 사다리_생성_확인() { |
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.
@DisplayName 어노테이션을 이용하여 더 테스트를 명확하게 설명 가능해요!
GreaterThanOne numberOfPerson = GreaterThanOne.from(5); | ||
|
||
//when | ||
LadderCreator ladderCreator = new LadderCreator(numberOfRow, numberOfPerson); |
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.
매개변수가 많을때는 생성자보다 빌더 패턴을 고려해보는것도 좋겠네요!
LadderCreator ladderCreator = new LadderCreator(numberOfRow, numberOfPerson); | ||
|
||
//then | ||
assertThat(ladderCreator).isNotNull(); |
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.
사다리 생성을 확인할때 notnull임을 검증하는것도 좋으나, row가 3이고 사람이 5인거를 검증하는게 더 명확해 보입니다!
void 사다리_사람_예외_처리_확인() { | ||
//when | ||
GreaterThanOne numberOfPerson = GreaterThanOne.from(3); | ||
LadderCreator ladderCreator = new LadderCreator(GreaterThanOne.from(2), numberOfPerson); |
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.
New ladderCreator() 보다는 메서드 체이닝 방식으로 생성자를 만들수 있는 빌더 패턴을 고려해보세요!
LadderCreator ladderCreator = new LadderCreator(row, numberOfPerson); | ||
LadderGame ladderGame = new LadderGame(ladderCreator); | ||
|
||
ladderCreator.drawLine(Position.from(0),Position.from(0)); |
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.
Drawline이 3개의 메서드로 로직이 겹치는것 같아요 private 메서드로 빼서 공통 로직을 구현해보는게 어떨까요?
//ladderCreator.drawLine(Position.from(1),Position.from(2)); | ||
ladderCreator.drawLine(Position.from(2),Position.from(1)); | ||
ladderCreator.drawLine(Position.from(3),Position.from(0)); | ||
ladderRunner.run(Position.from(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.
사다리 출력 시 검증하는 로직이 없는것 같네요!
void 한_칸_사다리_이동() { | ||
//when | ||
GreaterThanOne numberOfPerson = GreaterThanOne.from(2); | ||
Row row = new Row(numberOfPerson); |
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.
New row보다 from 메서드 사용이 나아보여요!
사다리 출력 기능만 구현했습니다..추가 구현 후 다시 pr보내겠습니다