-
Notifications
You must be signed in to change notification settings - Fork 47
HTTP 웹 서버 2단계 - 리팩토링 #33
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
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.
시간이 걸리기는 했지만 정말 객체지향적으로 구현 잘 했다. 💯
칭찬해 주고 싶다.
작은 피드백 몇 개 남겼으니 개선해 봐라.
import domain.HttpRequest; | ||
import domain.HttpResponse; | ||
|
||
public class AbstractController implements Controller { |
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.
AbstractController을 직접 생성하지 못하도록 abstract 클래스로 구현해 본다.
@Override | ||
public void service(HttpRequest request, HttpResponse response) { | ||
|
||
} |
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.
request method에 따라 doGet/doPost로 분기하는 로직이 있어야 하지 않을까?
|
||
} | ||
|
||
public void doGet(HttpRequest request, HttpResponse response) { |
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이 아니라 protected로 구현
|
||
} | ||
|
||
public void doPost(HttpRequest request, HttpResponse response) { |
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이 아니라 protected로 구현
private Socket connection; | ||
private Map<String, Controller> controllers = new HashMap<>(); |
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.
이와 같이 구현해도 요청이 올 때마다 매번 Map이 초기화되지 않을까?
Map을 한번 생성한 후 재사용하도록 구현한다.
Map 초기화하는 클래스를 RequestMapping과 같은 별도의 클래스로 분리해 본다.
BufferedReader.read()의 목적
charArray를 읽기 위한 것
byteArray를 읽고 싶다면 InputStream, BufferedInputStream을 이용할 것
body가 없다면 header에 content-length가 생기지 않는다.
이번 미션을 덕분에 다시 한 번 인터페이스, 추상클래스를 이용한 객체지향 프로그래밍의 참맛을 다시 느낄 수 있었습니다.
초반에 TDD로 하려고 마음을 먹고 덤벼들었으나 아직 제 실력으로는 테스트하기 힘든 부분들이 있어 TDD를 하지 못한 것이 조금 아쉬웠지만, 리팩토리 잘 한 것으로 만족합니다. 하하.