-
Notifications
You must be signed in to change notification settings - Fork 432
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
Step2 - 볼링 점수판(그리기) #993
base: mnyok
Are you sure you want to change the base?
Step2 - 볼링 점수판(그리기) #993
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.
객체 지향 프로그래밍을 하기 위해 객체를 추출하고, 테스트를 추가하느라 노력한 흔적이 느껴지네요. 💯
단, 지금 구현 로직을 보면 각 상태에 따른 if문이 무수히 많이 등장하는데요.
자바의 다형성을 적용해 if문을 제거하기 위해 도전을 해보면 어떨까요?
다소 쉽지 않을 수 있는데요. 한번 도전해 보면 좋겠어요.
@@ -0,0 +1,16 @@ | |||
package bowling.domain; | |||
|
|||
public interface Frame { |
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.
인터페이스에 메서드 수가 너무 많다.
메서드 수를 줄일 수 있는 방법을 찾아보면 어떨까?
FrameStatus getFirstStatus(); | ||
FrameStatus getSecondStatus(); | ||
FrameStatus getThirdStatus(); |
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.
State getState()
와 같이 하나로 합쳐서 구현해 보는 것은 어떨까?
|
||
|
||
public Hit(int hit) { |
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.
👍
} | ||
|
||
@Override | ||
public FrameStatus getThirdStatus() { |
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.
각 상태에 따른 if 문이 너무 많다.
자바의 다형성을 적용해 if문을 최소화하도록 도전해 보면 어떨까?
@@ -0,0 +1,83 @@ | |||
package bowling.domain; | |||
|
|||
public class NormalFrame implements Frame { |
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.
NormalFrame과 FinalFrame을 보면 중복 코드가 많다.
AbstractFrame과 같은 객체를 추가해 NormalFrame과 FinalFrame의 중복 로직을 제거해 보면 어떨까?
No description provided.