-
Notifications
You must be signed in to change notification settings - Fork 26
2주차 미션 / 서버 2조 황정안 #50
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
base: main
Are you sure you want to change the base?
Conversation
…word in Row class
kmw10693
left a comment
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,8 +1,76 @@ | |||
| public class Ladder { | |||
| Validation validation; | |||
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.
Validation은 private으로 접근 제어를 안하신 이유가 궁금하네요!
| private final int RIGHT=1; | ||
| private final int LEFT=-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.
enum으로 따로 빼시면서 관리하는게 어떨까요?
| if(naturalNumber<0){ | ||
| try { | ||
| throw new IllegalAccessException("Invalid deposit amount"); | ||
| } catch (IllegalAccessException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| } |
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 interface LadderCreator { | ||
| Row[] getRows(); | ||
| void drawLine(Position row, Position col); |
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 numberOfPerson = GreaterThanOne.from(5); | ||
|
|
||
| //when | ||
| LadderUserCreator ladderUserCreator = new LadderUserCreator(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 ladderUserCreator = new LadderCreator(numberOfRow, numberOfperson)
이렇게 수정하는게 좋아보입니다!
시간 내로 할 수 없을 것 같아 그냥 조금 더 천천히 고민 하고 올리고 싶어 지금 올리게 되었습니다.
기능은 다 구현 했으나, 리팩토링과 테스트 부분이 아쉬워 추후에 더욱 수정하여 다시 올리겠습니다!