-
Notifications
You must be signed in to change notification settings - Fork 708
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
3주차 - Step4 사다리(리팩토링) 리뷰요청 드립니다..! #221
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.
피드백을 잘 반영해 주셨습니다. 👍
설계한 것을 소리 내어 읽어 보고 말이 되는지 확인해 보는 것이 많은 도움이 된답니다.
그 외에도 몇 가지 의견을 남겨 놓았으니 충분히 고민하고 도전해 보세요!
진행 과정에서 궁금한 점은 댓글이나 Slack을 통해 물어보세요.
Prizes prizes = Prizes.from(InputView.askPrizes(), players.numberOfPlayers()); | ||
Prizes prizes = Prizes.from(InputView.askPrizes()); | ||
GameInfo gameInfo = GameInfo.of(players, prizes); | ||
|
||
Height height = Height.from(InputView.askHeight()); | ||
|
||
Ladder ladder = Ladder.from(players, height); |
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.
GameInfo
와 Ladder
를 가진 LadderGame
클래스를 만들어 보면 어떨까요?
|
||
GameResult gameResult = GameResult.of(players, ladder, prizes); | ||
GameResult gameResult = GameResult.of(ladder, gameInfo); |
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
에서 GameResult
를 생성한다."라는 설계는 어떨까요? 이렇게 하면 어떤 다른 곳에서 해당 객체를 생성할 때 생산자의 정보를 필요로 하는 것을 줄일 수 있어요. 아울러 생산자와 생성된 객체 사이의 특별한 관계를 전해주기도 합니다.
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에 gameInfo랑 ladder가 있으니까 LadderGame에서 GameResult를 생성하는것이 맞겠네요! 피드백 감사합니다!!
return position; | ||
} //TODO: 이 로직을 Bar 객체로 위임하고 싶은데, Bar 2개를 사용해서 위치를 갱신하는 방식이라 이 곳에서 처리하는 상태 | ||
return position; // 위의 경우가 아니면 위치 유지(패스) | ||
} //TODO: 이 부분에 대한 질문을 https://github.com/next-step/java-ladder/pull/207 피드백 주신 이 곳에 남겼습니다. |
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.
질문에 대한 답변은 Slack을 통해 남겼어요. 👍
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.
피드백을 전부 잘 반영해 주셨습니다. 💯
간단한 생각거리를 남겼으니 코드에 반영해 주셔도 좋습니다.
진행 과정에서 궁금한 점은 댓글이나 Slack을 통해 물어보세요.
src/main/java/ladder/domain/Bar.java
Outdated
@@ -2,17 +2,29 @@ | |||
|
|||
public class Bar { |
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.
아래의 질문에 답해 보면 좋을 것 같아요.
Bar
인스턴스가 만들어지는 경우의 수는 몇 가지 일까요?- 미리 생성하여 필요할 때마다 사용해 볼 수 있을까요?
- 위의 방식은 어떤 장점이 있을까요?
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.
-
Point로 바꾸었다고 가정했을 때, 아래 3가지 경우에 point를 생성할 수 있습니다.
- 왼쪽 point가 없고, 오른쪽 point가 있을 때, (생성되면 왼쪽으로 연결)
- 왼쪽 point가 있고, 오른쪽 point가 없을 때, (생성되면 오른쪽으로 연결)
- 양쪽 point가 모두 없을 때 (아래로 연결)
-
Point 인스턴스가 생성되기 위해서는 위의 3가지 조건에만 가능하고, 각 생성 조건은 결국 연결되는 방향을 결정합니다. 그러므로 생성조건 3가지를 '방향'이라는 Enum에 각각 정의 해두고 사용하면 될 것 같습니다.
-
장점
- 어떤 조건에서 point가 생성되고, 어느 방향으로 연결되는지 명확하게 표현할 수 있습니다.
- 불가능한 생성 조건 (true, true)를 사전에 방지할 수 있습니다.
- 게임의 룰이 바뀌었을 때 Enum만 수정하면 되므로 결합도를 낮출 수 있습니다.
주신 질문에 답을 작성하다보니 구현 방향이 정해지네요! 감사합니다ㅎㅎ
혹시나 제 답변에서 잘못된 부분이나 추가해주실 부분이 있으면 조언부탁드립니다!
src/main/java/ladder/domain/Bar.java
Outdated
|
||
private Bar(boolean bar) { | ||
this.bar = bar; | ||
private Bar(boolean left, boolean right) { |
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.
"가로 라인은 겹치지 않는다."라는 요구 사항을 코드로 표현해 보면 어떨까요?
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.
Direction Enum이 추가됌에 따라 Direction에 (true, true)를 검증하는 메서드를 만들었습니닷.. 올바르게 개선한 것인지 궁금합니다..!
private void validationMovableToLeft() { | ||
if (unmovableToLeft()) { | ||
if (!isMovableToLeft()) { |
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.
아래의 글을 읽고 코드에 반영하면 어떨까요?
https://schneide.blog/2014/08/03/dont-ever-not-avoid-negative-logic
Height height = Height.from(InputView.askHeight()); | ||
|
||
GameInfo gameInfo = GameInfo.of(players, prizes); | ||
Ladder ladder = Ladder.from(players, height); |
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
가 Players
에 의존하는 구조를 바꿔 볼 수 있을까요?
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.
피드백을 전부 잘 반영해 주셨습니다. 💯
질문에 대한 답변은 코멘트로 남겼어요.
간단한 생각거리를 남겼으니 코드에 반영해 주셔도 좋습니다.
다음 리뷰 요청 때는 Merge 하도록 하겠습니다.
private boolean right; | ||
|
||
Direction(boolean left, boolean right) { | ||
validationDirection(left, right); |
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.
이미 요구 사항을 Direction
으로 잘 표현하였어요. 👍
validationDirection(left, right); |
return Collections.unmodifiableList(points); | ||
} | ||
|
||
|
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 | ||
public interface PointGenerator { | ||
|
||
boolean generatePoint(); |
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.
"PointGenerator
는 boolean
을 생성한다."라는 설계는 자연스러울까요?
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.
수많은 피드백을 반영하고자 대단히 고생 많으셨습니다. 💯
"인내는 쓰고 열매는 달다."라는 말처럼 정말 달콤한 열매를 수확했길 바랍니다.
이만 Merge 하겠습니다.
질문에 빠른 답변 감사합니다!! 👍 👍 👍 👍 👍
Bar객체가 방향(Direction)을 가지게 해보라는 피드백을 주셨었는데요,
이에 대한 질문을 피드백에 댓글 로 남겼습니다..!
조금 멍청한 질문일지 모르겠지만
사다리를 구현하면서 가장 고민을 많이 한 부분이라
바쁘시겠지만 조언 부탁드리겠습니다..!!
나머지 피드백은 모두 반영했습니다-!