Skip to content

Step2 #39

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

Merged
merged 5 commits into from
Jan 28, 2019
Merged

Step2 #39

merged 5 commits into from
Jan 28, 2019

Conversation

Sehun-Kim
Copy link

WAS Step2

requestHandler

리팩토링 기준은 중복을 제거하는 것에 초점을 맞추면서, 예시로 주신 클래스의 메소드의 매개변수와 리턴값을 보며 의미를 파악해 보았습니다. 최대한 예시의 메소드의 형식에 맞추어 리팩토링하였습니다.

Controller interface

인터페이스를 활용하여 컨트롤러의 실행 부분의 중복을 제거하였습니다.

  • service() 메소드를 가지는 Controller 인터페이스
  • Controller 인터페이스를 구현한 AbstractController 클래스
  • AbstractControllerdoGet(), doPost() 메소드를 가지고 있다.

DispatchPath enum

pathController를 갖는 enum을 만들어 path에 맞는 컨트롤러에 맵핑하는 곳의 중복과 if문을 제거하였습니다.

Copy link
Contributor

@javajigi javajigi left a comment

Choose a reason for hiding this comment

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

전체적으로 구현 잘 했네. 💯
소소한 피드백 몇 개 남겼으니 개선해 봐라.


@Override
public void service(HttpRequest request, HttpResponse response) throws IOException {
if (request.getMethod().equals(HttpMethod.GET))
Copy link
Contributor

Choose a reason for hiding this comment

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

request.isGet() 또는 request.matchMethod(HttpMethod.GET)는 어떨까?


Controller login = DispatchPath.findController(loginPath);
logger.debug("loginPath : {}", login);
assertTrue(login instanceof LoginController);
Copy link
Contributor

Choose a reason for hiding this comment

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

테스트 메소드 하나에 너무 많은 경우를 테스트하고 있다.
반복 테스트를 줄이던가 테스트 수를 줄여도 되지 않을까?

@javajigi javajigi merged commit c6159dd into code-squad:Sehun-Kim Jan 28, 2019
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.

2 participants