-
Notifications
You must be signed in to change notification settings - Fork 6
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차 스프린트 리팩토링을 진행한다. #154
1차 스프린트 리팩토링을 진행한다. #154
Conversation
public Badge provideBadge(Questionlist questionlist, List<ChecklistQuestion> questions) { | ||
int categoryScore = calculateCategoryScore(this, questionlist, questions); |
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 import를 안쓰는 게 더 좋은 것 같아 보여요!
public static int calculateCategoryScore(Category category, Questionlist questionlist, List<ChecklistQuestion> questions) { | ||
List<ChecklistQuestion> filteredQuestions = questionlist.filterQuestions(category, questions); | ||
|
||
if (filteredQuestions.isEmpty()) { | ||
return 0; | ||
} | ||
|
||
int maxScore = Grade.calculateMaxScore(filteredQuestions.size()); | ||
int totalScore = Grade.calculateTotalScore(filteredQuestions); | ||
|
||
return totalScore * 10 / maxScore; | ||
} |
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.
점수 계산하는 두 메서드에서 중복을 제거할 수 있을 것 같아 보여요
@@ -109,8 +114,8 @@ private void createChecklistQuestions(ChecklistCreateRequest checklistCreateRequ | |||
List<QuestionCreateRequest> questions = checklistCreateRequest.questions(); | |||
validateQuestion(questions); | |||
for (QuestionCreateRequest questionCreateRequest : questions) { | |||
Integer questionId = questionCreateRequest.questionId(); | |||
ChecklistQuestion checklistQuestion = new ChecklistQuestion(checklist, questionId, | |||
Question question = questionList.findById(questionCreateRequest.questionId()); |
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.
메서드 내에서 사용되는 부분이 없어 보입니다
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 할게요~
import com.bang_ggood.category.domain.Category; | ||
import java.util.List; | ||
|
||
public class ChecklistScore { |
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.
점수에 대한 로직을 다른 도메인으로 분리하는 것은 좋은 것 같네요!
.mapToInt(CategoryScoreReadResponse::score) | ||
.sum() / categoryScores.size(); | ||
private int getChecklistScore(Checklist checklist) { | ||
return calculateTotalScore(checklist.getQuestions()); |
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 import를 사용하지 않는 것이 더 명확할 것 같아요!
❗ Issue
✨ 구현한 기능
📢 논의하고 싶은 내용
🎸 기타