-
Notifications
You must be signed in to change notification settings - Fork 26
2주차 미션 / 서버 2조 정윤아 #47
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
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.
코드 짜느라 고생하셨어요 ㅎㅎ!
객체지향적으로 코드를 짜보려고 노력해보신 모습이 보여 인상 깊습니다!
2주차 미션 하느라 고생하셨습니다!
| private LadderCreator ladderCreator; | ||
| private RunGame runGame; |
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.
클래스를 final로 선언해서 불변 객체로 만들면 어떨까요?
| LadderCreator ladderCreator = new LadderCreator(Index.from(5), Index.from(7), false); | ||
|
|
||
| PositionOfLine position = PositionOfLine.of(Index.from(3), Index.from(2)); | ||
|
|
||
| ladderCreator.drawLine(position); | ||
|
|
||
| Assertions.assertThat(ladderCreator.LineAlreadyExisting(position.getX(), position.getY())).isEqualTo(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.
테스트 코드를 잘 작성해주셨네요! 테스트 코드 작성에 있어, BDD(given when then)방식으로 테스트를 해볼수 있습니다! 한번 BDD 에 대해 알아보세요!
| @@ -0,0 +1,19 @@ | |||
| public class LadderGameFactory { | |||
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.
객체지향을 살릴 수 있는 디자인 패턴중 팩터리 메서드 패턴이란 것이 있습니다!
팩터리 메서드 패턴은 클래스의 인스턴스 생성을 서브 클래스에게 맡기는 것인데요!
지금 이 코드는 메서드가 겹쳐 코드의 중복도가 높은 것 같습니다.
- LadderGameFactory를 추상 클래스(abstract class)로 선언합니다.
- 추상 클래스 내에 공통으로 게임을 만드는 createGame() 메서드를 선언합니다.
- createLadderGame 클래스와 createRandomLadderGame 클래스는 1번 추상 메서드를 확장하여 각각의 인스턴스를 반환합니다.
- 구상 클래스(createLadderGame, createRandomLadderGame) 클래스의 createGame() 메서드를 통해 객체를 반환받습니다.
이런식으로 하면 코드를 확장할때도, 객체지향적으로 용이해보이네요!
디자인 패턴 중 팩터리 메서드 패턴에 대해 공부해보시면 좋을 것 같아요!
기능 구현은 완료하였으나 리팩토링이 더 필요할 것 같습니다. 추가적으로 진행해보겠습니다!