-
Notifications
You must be signed in to change notification settings - Fork 47
Step1 #30
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
Step1 #30
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.
큰 도움을 받지 않고도 구현 잘 했네. 👍
피드백 좀 남겨본다.
|
||
private DataBase userRepository = DataBase.getInstance(); | ||
|
||
private final Logger log = LoggerFactory.getLogger(UserController.class); |
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.
static final 상수로 구현
private DataBase userRepository 보다 앞에 위치하는 것이 낫겠음.
|
||
private final Logger log = LoggerFactory.getLogger(UserController.class); | ||
|
||
@RequestMapping(method = "GET", path = "/list.html") |
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.
HttpMethod가 있는데 이 enum을 사용하도록 하는 것이 낫지 않을까?
response.setStatue(FOUND); | ||
response.loginSuccess(); | ||
|
||
return ModelAndView.viewOf("index.html"); |
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.
spring 처럼 "redirect"를 붙이면 프레임워크 내에서 FOUND로 처리해주면 어떨까?
프레임워크를 쓰는 개발자가 FOUND 지정을 하도록 하기보다..
public Map<String, String> getParams() { | ||
return params; | ||
} | ||
|
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 String getParam(String key) {
}
위와 같은 메소드가 있어도 좋지 않을까?
this.controllers = beanPool.getBeans(); | ||
} | ||
|
||
public Response retrieveViewName(Request request) throws IllegalAccessException, InvocationTargetException, InstantiationException, IOException, NoSuchMethodException { |
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.
매 요청마다 Controller에서 해당 method를 찾지 말고 Controller의 모든 method를 caching하는 구조이면 어떨까?
예를 들어 Map의 key와 value를 다음과 같이 구성해 보면 어떨까?
public class HandlerKey {
private String url;
private HttpMethod requestMethod;
public HandlerKey(String url, HttpMethod requestMethod) {
this.url = url;
this.requestMethod = requestMethod;
}
}
value는 다음과 같이 메소드를 실행하기 위해 필요한 정보를 저장하고 있는 객체를 추가한다.
// method를 실행하기 위한 정보를 가져야 한다.
// 즉, 실행할 method와 method의 인스턴스
public class HandlerExecution {
public ModelAndView handle(HttpServletRequest request, HttpServletResponse response) throws Exception {
return null;
}
}
for (String element : html) { | ||
out.writeBytes(element); | ||
} | ||
return baos.toByteArray(); |
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.
메소드가 하는 일이 너무 많다.
메소드가 한 가지 일만 하도록 리팩토링한다.
미루고 미루다가 이제 pr을 날려야 할 것 같아서, 마무리 해 보았습니다.ㅎㅎ
어노테이션 기반으로 만들어보려고 했고, 만들다 보니 오버 엔지니어링이 된 건 아닌가 싶을 정도로 조잡한 느낌입니다.ㅠ
frontController에서 컨트롤러를 찾고 메소드를 실행하여 ModelAndView를 받아오는 형식으로 만들었고,
예외처리도 할 수 있도록 만들어보았습니다.