Skip to content
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

[MVC 구현하기 - 3단계] 몰리(김지민) 미션 제출합니다. #826

Merged
merged 19 commits into from
Oct 3, 2024

Conversation

jminkkk
Copy link

@jminkkk jminkkk commented Sep 30, 2024

안녕하세요 알파카 🙌

이번 PR에 드디어 DispatcherServlet이 app 모듈에서 탈출했네요 (ㅋㅋㅋ)
지난 리뷰에서 말씀 드린 애플리케이션의 베이스 패키지를 DispatcherServlet에 하드코딩하는 것이 아닌,
SerlvetContext를 통해 DispatcherServlet에 주입하는 방식으로 변경했습니다.

의문이 드는 부분이나 의견 있다면 편하게 부탁드립니다!
이번 리뷰도 잘 부탁드려요 🔥

Copy link
Member

@slimsha2dy slimsha2dy left a comment

Choose a reason for hiding this comment

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

일단 리뷰가 너무 늦어져서 정말 죄송합니다..ㅜ
전체적으로 미션 코드는 너무 깔끔해서 따로 피드백이 필요 없다고 느껴졌습니다!
또 제가 학습 테스트에서 많이 헤맸는데 몰리의 구현을 보면서 많이 배울 수 있었네요.
질문이나 얘기해볼 점 위주로 리뷰를 남겼는데 이에 대한 답변만 남겨주시면 바로 merge하겠습니다!
그리고 이전 pr도 추가 리뷰 있었는데 혹시 확인 못하셔서 안 남기신 거면 확인 부탁드릴게요. 감사합니다.


@Deprecated
Copy link
Member

Choose a reason for hiding this comment

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

@Deprecated 활용 저는 생각도 못했는데 괜찮네요..

Comment on lines 33 to 37
if (model.size() == ONE_MODEL_SIZE) {
return model.values().stream()
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("모델이 비어있습니다. 데이터를 확인해주세요."));
}
Copy link
Member

Choose a reason for hiding this comment

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

[질문] orElseThrow하는 상황이 언제 발생하나요?

Copy link
Author

Choose a reason for hiding this comment

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

어라라 그러네요 데이터가 없다고 예외를 던지는 게 이상하네요
null을 반환하는 게 낫겠어요
아르르르파카 최고 👍

Comment on lines +57 to +58
"alpaca", new User("alpaca", 25),
"moly", new User("moly", 20)
Copy link
Member

Choose a reason for hiding this comment

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

??

Comment on lines +19 to +20
this.beans = createBeans(classes);
this.beans.forEach(this::setFields);
Copy link
Member

Choose a reason for hiding this comment

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

오우 저는 빈을 등록할 때 바로 생성을 진행하고 초기화할 때 빈이 없다면 재귀적으로 빈을 등록하는 방식밖에 생각을 못해서 코드가 무진장(큰스님 ㅋㅋ) 더러워졌는데 몰리아티 교수님 방식이 훨씬 깔끔해서 읽기 편하고 좋네요..ㅎㅎ
역시 김 짱 리

Copy link
Author

Choose a reason for hiding this comment

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

저도 생성자 주입을 도전해보고 싶긴 한데 너무 복잡하기도 하고 이번 학습 테스트가 요구하는 것과는 다른 것 같아서 시도하지 않았습니다 ㅎㅎ 파카 코드 훔쳐보러 가야겠네요 ⚡️

Comment on lines +49 to +50
return !Modifier.isStatic(modifiers) &&
!Modifier.isFinal(modifiers);
Copy link
Member

Choose a reason for hiding this comment

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

정적 변수나 final이 아닌 경우에는 항상 주입을 진행하네요.
물론 지금 코드에서는 어노테이션 기반이 아니기 때문에 주입이 필요한 필드인지 알기 힘들어서 지금 구조에서는 어쩔 수 없었을 것 같네요.
만약 public 생성자가 하나인 경우라면 생성자의 매개변수를 통해 주입이 필요한 필드를 알아낼 수 있을 것 같긴 합니다리미!

Copy link
Author

Choose a reason for hiding this comment

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

오 생각해보지 못했는데 생성자의 매개변수를 통해 주입이 필요한 필드를 알아내는 방법도 좋네요 👍

.filter(bean -> aClass.isAssignableFrom(bean.getClass()))
.findFirst()
.map(aClass::cast)
.orElseThrow(() -> new RuntimeException("Beand을 찾을 수 없습니다."));
Copy link
Member

Choose a reason for hiding this comment

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

Beand는 무엇인가요?(빈틈의 실 발견)

Comment on lines 18 to 33
public static Set<Class<?>> getAnnotatedClassesInPackage(
final String packageName,
final Class<? extends Annotation> annotation
) {
Reflections reflections = new Reflections(packageName, Scanners.TypesAnnotated);
return reflections.getTypesAnnotatedWith(annotation);
}

public static Set<Class<?>> getAnnotatedClassesInPackage(
final String packageName,
final Class<? extends Annotation>... annotations
) {
Reflections reflections = new Reflections(packageName, Scanners.TypesAnnotated);
return Arrays.stream(annotations)
.flatMap(annotation -> reflections.getTypesAnnotatedWith(annotation).stream())
.collect(Collectors.toSet());
Copy link
Member

Choose a reason for hiding this comment

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

아래 메서드만 있으면 위의 메서드는 없어도 되지 않나요?

Copy link
Author

Choose a reason for hiding this comment

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

이인정
그러네요 삭제하겠습니다 최고 🔥

return reflections.getSubTypesOf(Object.class);
}

public static Set<Class<?>> getAnnotatedClassesInPackage(
Copy link
Member

Choose a reason for hiding this comment

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

필요한 메서드를 추가적으로 구현해서 사용한 점이 아주 좋네요!
대신 getAllClassesInPackage는 사용하지 않는 것 같은데 그냥 구현하신 건가요?

Copy link
Author

Choose a reason for hiding this comment

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

ClassPathScanner라는 이름을 가진 객체에 뭔가 Package에 있는 특정 Annotation이 달린 Classes을 찾는 역할은 있는데 전체 클래스를 스캔하는 역할이 없는 게 어색해서 안 쓰더라도 남겼었어요 ㅎㅎ
그런데 아무래도 사용하지 않으면 제거하는 게 좋을 것 같군요... 제거하겠습니다! 👍

.filter(bean -> aClass.isAssignableFrom(bean.getClass()))
.findFirst()
.map(aClass::cast)
.orElseThrow(() -> new RuntimeException("Beand을 찾을 수 없습니다."));
Copy link
Member

Choose a reason for hiding this comment

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

김몰리: "Beand"

@jminkkk
Copy link
Author

jminkkk commented Oct 2, 2024

안녕하세요 파카
지난 PR에서 놓친 부분에 대한 코멘트 추가해놓았습니다 😁
마지막까지 파이팅 🔥

지난 PR

Copy link
Member

@slimsha2dy slimsha2dy left a comment

Choose a reason for hiding this comment

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

이번 미션 동안 다른 할 일도 많았어서 엄청 바쁘셨을텐데 수고 많으셨습니다!!
저도 여러 사정 상 리뷰가 좀 늦어졌던 점은 정말 죄송합니다 ㅜㅜ
테스트를 꼼꼼하게 짜는 점과 깔끔해서 읽기 좋은 코드가 몰리의 장점이었던 것 같아요!
이번 미션 수고하셨고 다음 마지막 미션도 파이팅팅탱탱

@slimsha2dy slimsha2dy merged commit 25c299a into woowacourse:jminkkk Oct 3, 2024
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