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

[DEV-29] CalculateDetailGraduationUseCaseResolver 구현 #252

Merged

Conversation

5uhwann
Copy link
Member

@5uhwann 5uhwann commented Apr 21, 2024

✅ 작업 내용

해당 PR에서 논의한 내용을 바탕으로 CalculateDetailGraduationUseCaseResolver를 새로 구현하였습니다.

  • CalculateDetailGraduationUseCaseResolver 구현

🤔 고민 했던 부분

  • 각 GraduationCategory를 지원하는 CalculateDetailGraduationUseCase를 동적으로 결정하기 위한 방법으로 SpringMVC의 DispatcherServlet에 영감을 받아 모든 CalculateDetailGraduationUseCase를 모두 주입받는 것이 아닌 ApplicationContext를 통해 CalculateDetailGraduationUseCase타입 빈들을 조회+리스트업 후 GraduationCategory 여부에 따라 resolve하는 방식으로 구현하였습니다.

위 사항을 반영하여 수정한 다이어그램입니다.
Screenshot 2024-04-21 at 23 34 27

🔊 도움이 필요한 부분!!

  • CalculateDetailGraduationUseCaseResolver의 패키지 위치가 어디가 좋을지 의견 부탁드립니다!

Copy link

@5uhwann 5uhwann changed the title [DEV-29] CalculateDetailCategoryResultResolver 구현 [DEV-29] CalculateDetailGraduationUsecaseResolver 구현 Apr 21, 2024
@5uhwann 5uhwann self-assigned this Apr 21, 2024
@5uhwann 5uhwann added the ✨ feat 새로운 기능 개발 혹은 기존 기능 변경 label Apr 21, 2024
@5uhwann 5uhwann added this to the 리팩토링 milestone Apr 21, 2024
@5uhwann 5uhwann changed the title [DEV-29] CalculateDetailGraduationUsecaseResolver 구현 [DEV-29] CalculateDetailGraduationUseㅊaseResolver 구현 Apr 21, 2024
@5uhwann 5uhwann changed the title [DEV-29] CalculateDetailGraduationUseㅊaseResolver 구현 [DEV-29] CalculateDetailGraduationUseCaseResolver 구현 Apr 21, 2024
@github-actions github-actions bot added the D-5 label Apr 22, 2024
Copy link
Member

@stophwan stophwan left a comment

Choose a reason for hiding this comment

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

반영되니까 훨씬 간결하고 좋다!! Resolver는 api도 application도 아니라 별도의 패키지로 분리하는 것이 맞다 생각해. support 같은 패키지를 하나 추가하는건 어떤지?

Comment on lines 36 to 40
private void initCalculateDetailGraduationUseCase() {
Map<String, CalculateDetailGraduationUseCase> matchingBeans = applicationContext.getBeansOfType(
CalculateDetailGraduationUseCase.class);
this.calculateDetailGraduationUseCases = new ArrayList<>(matchingBeans.values());
}
Copy link
Member

Choose a reason for hiding this comment

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

이 코드만 보면 생성자 주입으로 모든 CalculateDetailGraduationUseCase의 빈을 주입하는 것과 큰 차이는 없어보이는데, ApplicationContext를 사용함으로서 얻는 장점이 있나?

Copy link
Member Author

@5uhwann 5uhwann Apr 22, 2024

Choose a reason for hiding this comment

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

생각해보니 그렇네요..! 빈 조회 후 특정 방법에 대한 정렬이나 기본 빈 처리 전략 없이 해당 타입으로만 조회를 하니 List로 주입받는것과 다름이 없군요
원래는 GraduationCategory에 해당하는 빈만 조회하고 싶었는데 className 기반으로 조회를 할 경우 변경에 대한 유연성이 너무떨어져 해당 방식은 기각했는데 그렇다면 각 CalculateDetailGraduationUseCase 빈 등록시 @Quilipier를 통해 GraduationCategory EnumType value로 구분자를 추가하여 등록 후 GraduationCategory에 해당하는 빈만 조회하여 반환하는 방식은 어떤가요?

  1. 모든 빈 List로 주입 후 support 여부로 체크 후 반환
    • 코드가 간결해짐
    • CalculateDetailGraduationUseCase 타입 빈들을 모두 체크해야 함 (어차피 몇개 없어서 큰 문제는 아닌거 같긴 합니다)
  2. Qualifier 어노테이션을 통해 빈 등록 시 GraduationCategory enum value로 구분 후 GraduationCategory에 해당하는 빈 조회
    • 필요한 빈만 조회 후 반환 가능
    • GraduationCategory 변경 시 Qualifier 어노테이션 value 수정 필요 -> 마찬가지로 변경의 유연성 떨어짐

어떤 방법이 더 괜찮을지 의견 부탁드립니다! @stophwan @Hoya324

Copy link
Member

Choose a reason for hiding this comment

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

나는 1번 방안이 더 나은거 같아. 수환 말대로 className 기발 조회가 변경 유연성이 떨어지고, 모든 빈을 주입하는게 큰 차이가 없다는 점에서!

Copy link
Member Author

Choose a reason for hiding this comment

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

[a863510] 반영완료했습니다!

Copy link

sonarcloud bot commented Apr 24, 2024

Copy link
Member

@stophwan stophwan left a comment

Choose a reason for hiding this comment

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

👍 👍

@5uhwann 5uhwann merged commit e495969 into develop Apr 24, 2024
3 checks passed
@5uhwann 5uhwann deleted the feature/DEV-29-calculate_detail_graduation_usecase_resolver branch April 24, 2024 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
D-3 ✨ feat 새로운 기능 개발 혹은 기존 기능 변경 size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants