Skip to content

Conversation

@jungan777
Copy link

시간 내로 할 수 없을 것 같아 그냥 조금 더 천천히 고민 하고 올리고 싶어 지금 올리게 되었습니다.
기능은 다 구현 했으나, 리팩토링과 테스트 부분이 아쉬워 추후에 더욱 수정하여 다시 올리겠습니다!

Copy link

@kmw10693 kmw10693 left a comment

Choose a reason for hiding this comment

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

코드 짜느라 고생하셨습니다!

@@ -1,8 +1,76 @@
public class Ladder {
Validation validation;
Copy link

Choose a reason for hiding this comment

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

Validation은 private으로 접근 제어를 안하신 이유가 궁금하네요!

Comment on lines +6 to +7
private final int RIGHT=1;
private final int LEFT=-1;
Copy link

Choose a reason for hiding this comment

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

enum으로 따로 빼시면서 관리하는게 어떨까요?

Comment on lines +5 to +11
if(naturalNumber<0){
try {
throw new IllegalAccessException("Invalid deposit amount");
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
Copy link

Choose a reason for hiding this comment

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

이 검증 메서드를 따로 빼는건 어떨까요?

Comment on lines +5 to +7
public interface LadderCreator {
Row[] getRows();
void drawLine(Position row, Position col);
Copy link

Choose a reason for hiding this comment

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

디자인 패턴 중 팩터리 패턴을 공부해보시면 좋을 것 같습니다!
상위 클래스를 인터페이스나 추상 클래스로 지정하고, 하위 클래스에서 인스턴스를 만들지 결정하는 패턴입니다!

GreaterThanOne numberOfPerson = GreaterThanOne.from(5);

//when
LadderUserCreator ladderUserCreator = new LadderUserCreator(numberOfRow, numberOfPerson);
Copy link

Choose a reason for hiding this comment

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

객체지향적으로 봤을때, 이 코드는 구상 클래스에 의존하고 있는 코드입니다.
인터페이스가 아닌 특정 구현을 사용하게 되어버리는 것이죠!
LadderCreator ladderUserCreator = new LadderCreator(numberOfRow, numberOfperson)
이렇게 수정하는게 좋아보입니다!

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