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-36] 졸업 검사 코드 리팩토링 #274

Merged
merged 18 commits into from
Jun 29, 2024

Conversation

stophwan
Copy link
Member

@stophwan stophwan commented Jun 27, 2024

Issue

Close #273

✅ 작업 내용

  • MajorGraduationType -> MajorType enum 클래스명을 변경하였습니다. 주전공/복수전공/부전공을 더 직관적으로 표현하는 클래스 명이라고 생각합니다.
  • CalculateGraduationService에 복수전공, 부전공일 시 분기처리하는 로직을 CalculateMajorGraduationService, CalculateBasicGraduationService로 옮겼습니다. 공통교양, 핵심교양의 경우 복수전공/부전공의 경우 분기처리는 관련이 없기 때문에 파사드 패턴의 상위 클래스인 CalculateGraduationService에 있는 것이 부적절하다고 생각했습니다.
  • xxxGraduationService의 경우 클래스들을 통일하여 중복된 메서드들을 제거하였습니다.
  • Port역할을 할 확률이 없는 UseCase를 제거하였습니다.
  • 각 카테고리별 독립적인 졸업 검사 모듈인 xxxGraduationManager를 스프링 빈을 등록했습니다. 특정 클래스가 멤버 변수를 가지고 있어 싱글톤으로 등록하지 못했었지만, [DEV-35] 학사안내문 업데이트 반영 #270 을 진행하며 해당 변수들을 담는 DTO를 만드는 방식으로 멤버변수를 제거했습니다.

🤔 고민 했던 부분

  • xxxGraduationService의 불필요한 클래스 증가, 중복코드 문제
    • 이수 학점 조회 API와 세부졸업결과 API의 경우 둘다 xxxGraduationManger를 호출하며 졸업결과를 반환하기 위한 세부로직이 들어갑니다.
    • 기존에는 이 역할을 하는 클래스들이 여러 클래스로 분리되어있었습니다. SRP에 따르면 하나의 클래스는 변경 가능성이 한 가지여야 하지만 다음과 같은 문제점을 내포하고 있었습니다.
    • 두 API에 비즈니스 로직이 둘 다 로직이 거의 동일하고 강하게 결합되어있어, 복수전공/부전공으로 관리 포인트가 늘어남에 따라 중복된 코드가 많아진다는 점. 하나의 클래스로 관리함으로서 관리할 포인트가 높고 메서드 재활용이 용이하다는 점. 두가지 이유로 여러 유스케이스를 합쳤습니다.

@stophwan stophwan added the ♻️ refactor 기본의 로직 변경 없이 코드 개선 label Jun 27, 2024
@stophwan stophwan self-assigned this Jun 27, 2024
Copy link

1 similar comment
Copy link

@5uhwann 5uhwann self-assigned this Jun 27, 2024
@github-actions github-actions bot added the D-5 label Jun 27, 2024
Copy link

sonarcloud bot commented Jun 28, 2024

Copy link
Member

@5uhwann 5uhwann left a comment

Choose a reason for hiding this comment

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

확인했습니다!
사전에 논의했던 대로 리팩토링이 잘 진행되어 중복 코드와 인터페이스를 줄여 명확한 책임을 부여할 수 있게 된거 같습니다! 무엇보다 최초에 의도했던 대로 CalculateGraduationService는 각 졸업 카테고리를 계산해주는 유스케이스들만 호출하고 그 외에 불필요한 로직을 제거한 것이 정말 좋은 거 같습니다!

  • 추가로 코드 포맷등은 제가 수정해서 커밋하였습니다! 말씀하셨던대로 이후 린트를 도입하는 것도 좋아보입니다!

@stophwan stophwan merged commit b9810ab into develop Jun 29, 2024
3 checks passed
@stophwan stophwan deleted the dev-36-graduate-code-refactor branch June 29, 2024 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
D-5 ♻️ refactor 기본의 로직 변경 없이 코드 개선 size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DEV-36] 졸업 검사 코드 리팩토링
2 participants