-
Notifications
You must be signed in to change notification settings - Fork 309
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
[톰캣 구현하기 - 1,2단계] 모디(전제희) 미션 제출합니다. #327
Conversation
Kudos, SonarCloud Quality Gate passed! 0 Bugs 0.0% Coverage The version of Java (11.0.20.1) you have used to run this analysis is deprecated and we will stop accepting it soon. Please update to at least Java 17. |
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.
모디 안녕하세요! 헙크입니다 ㅎㅎㅎ
리뷰하면서 많이 배웠습니다. 구조적인 것과 효율적인 패턴사용이 인상깊었어요. 사실 뭐가 이상하다 말씀드리기가 뭐할정도로 제가 봤을 때는 잘 구현하신 것 같아요.
몇 가지 간단한 커멘트 남겼습니다. 한 번 더 얘기를 나눠보고 바로 Approve하면 될 것 같아요! 고생하셨습니다.
private void validateRequestLineElementsCount(String[] elements) { | ||
if (elements.length != 3) { | ||
throw new HttpFormatException(); | ||
} | ||
} | ||
|
||
private void validateUrlAndQueryStringLength(String[] urlAndQueryString) { | ||
if (urlAndQueryString.length > 2) { | ||
throw new HttpFormatException(); | ||
} | ||
} |
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.
검증!! 꼼꼼하시군요 ㅎㅎㅎ
for (Handler handler : HANDLERS) { | ||
if (handler.supports(httpRequest)) { | ||
return handler; | ||
} | ||
} |
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 class MemberService { | ||
|
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 HttpResponse handle(HttpRequest request) { | ||
if (doesRequestContainsCookie(request)) { |
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.
handler에서 쿠키가 있는지 확인하는 것도 좋지만, HttpRequest 객체에게 쿠키가 있는지 물어보는 것도 좋을 것 같습니다! 쿠키가 있는지 알려주는 것은 HttpRequest의 책임에 조금 더 가깝지 않을까 생각해봤어요 ㅎㅎㅎ
|
||
public static HttpResponse register(HttpRequest httpRequest) { | ||
String body = httpRequest.getBody(); | ||
Map<String, String> requestParam = parseForm(body); |
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.
아마 중간에 GET 요청 방식에서 POST 요청 방식으로 바뀌었는데, 요거 변수명도 같이 안바뀐 것 같네요 ㅎㅎㅎ
이제 requestParam이 아니라 requestBody 어떠신가요!?
addRequestLine(outputStream); | ||
addHeaders(outputStream); | ||
addBody(outputStream); |
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.
아아 outputStream을 넘겨서 쭉쭉 써내려갈 수 있군여... 아니 학습테스트를 했었는데도 새롭네요 ㅋㅋㅋㅋ 배워갑니다 모디 ㅎㅎ
|
||
public static class Builder { |
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 (handler.supports(httpRequest)) { | ||
return handler; | ||
} | ||
} | ||
return HANDLER_NONE_MATCHED_DEFAULT; |
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.
스트림을 사용할 수도 있을 것 같네요
안녕하세요 헙크..!
하하 테스트 없이 굴러가는 불안한 코드로 일단 제출합니다!
아직 리팩터링할 부분이 당연히 많은데 3단계에서 추가적으로 고쳐보겠습니다!
큰 흐름에서 제안해주실 사항이나 하면서 좋다고 생각했던 아이디어들 말씀 주시면 수정에 참고하겠습니다~!