-
Notifications
You must be signed in to change notification settings - Fork 74
[team-08][BE] todo-list 2주차 #4 #194
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
[team-08][BE] todo-list 2주차 #4 #194
Conversation
… 업데이트 여부를 판단하는 로직을 위임
- ResponseEventDto 클래스 제거 - Section의 findSection 메서드 버그 수정
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.
안녕하세요, 리뷰어 Sigrid Jin입니다.
이번 프로젝트 정말 수고 많으셨구요. 클린코드의 입장에서 정말 장족의 발전이 있었다고 평해볼 수 있겠습니다.
많은 것을 가져가실 수 있던 시간이 되길 바라며, 다음에 다시 찾아뵙도록 하겠습니다. 궁금한 점 있으시면 언제든 디엠 부탁하구요. 감사합니다.
| ResponseCardDto responseCardDto = cardService.addCard(requestCardDto); | ||
| eventService.addEvent(new RequestEventDto(responseCardDto), Action.ADD); | ||
| return responseCardDto; | ||
| return cardService.addCard(requestCardDto); |
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.
서비스 객체로 책임과 역할을 분리시켜, 컨트롤러는 거들 뿐이라는 사실을 상기했습니다. 👍
| } else { | ||
| eventService.addEvent(new RequestEventDto(prevSection, responseCardDto), Action.MOVE); | ||
| } | ||
| cardService.updateCard(id, requestCardDto); |
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.
와 눈물이 나는 변화로군요 💯
|
|
||
| @GetMapping("/events") | ||
| public List<ResponseEventDto> getEvents() { | ||
| public List<Event> getEvents() { |
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.
이번에는 도메인 객체를 직접 넘겼지만, 결국 DTO 세트를 담아서 넘겨야 하는 시간이 올 것입니다.
누가 왜 그렇게 구현했나요, 무슨 차이가 있나요 라고 면접에서 물어본다면 대답하실 수 있기를 바랍니다.
| return result; | ||
| } | ||
|
|
||
| private static Section findSection(String sectionTitle) { |
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.
enum에 직접 비즈니스 로직을 넣어준 점 아주 좋습니다 👍
| List<Card> responseSection = result.get(findSection(section).sectionTitle); | ||
| responseSection.add(card); | ||
| } | ||
| return result; |
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.
result 도 별도의 object로 wrapping하는 것에 대해서는 어떻게 생각하시나요?
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.
@jypthemiracle 해당 메서드는 요청에 대한 응답값으로 넘겨줄 Map객체를 반환하는 메서드입니다. 하지만 서비스에서 해당 맵객체를 ResponseCardsDto로_ Wrapping하는데 굳이 또 감쌀 필요가 있는지 잘 모르겠습니다!
혹시 제가 놓친 이유가 있다면 알려주시면 감사하겠습니다!
| ADD((dto, action) -> new Event(dto, action)), | ||
| MOVE((dto, action) -> new Event(dto, action)), | ||
| UPDATE((dto, action) -> new Event(dto, action)), | ||
| REMOVE((dto, action) -> new Event(dto, action)); |
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 class ResponseCardsDto { | ||
|
|
||
| private Map<String, List<ResponseCardDto>> cards; | ||
| private Map<String, List<Card>> cards; |
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.
Card를 mapping하는 object를 별도로 wrapping해서 만들 수는 없을까요?
| return card.toResponseCardDto(); | ||
| } | ||
|
|
||
| @Transactional |
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.
이번 프로젝트의 마지막 숙제입니다.
@Transactional 의 쓰임과 작동 방식을 조사해서 자신만의 언어로 정리해주세요.
|
이만 머지하겠습니다. 커멘트 추가로 달아보시고 궁금한 점 있으시면 저에게 디엠 주세요. 즐거운 학습과정이 되시기 바랍니다. |
어느덧 마지막 pr을 보내는 날이 왔네요😿
시그리드 덕분에 많은 성장을 할 수 있었던것 같습니다! 항상 정성이 담긴 피드백을 주셔서 감사합니다~
이번 pr은 수요일 피드백을 적용하는것에 초점을 맞췄습니다!
리뷰 적용 사항
1. cardController의 add 메서드 return 값이 애매하다는 리뷰.
EventService를 CardService 내부로 이동.
변경 전 코드

변경 후 코드


2. responsCardDto에게 section 값을 비교하는 책임을 위임하기 & else 제거하기
3. put, delete 메서드에 최소한 요청 성공 여부를 알려주는 반환값 정도는 주도록 개선하기
{ "code" : "200", "message" : "성공", "content" : "{...}" }4. Action enum 내부에서 Event가 스스로 dto의값들을 사용하도록 개선하기
5. ResponseCardsDto에서 Map의 키값을 enum 타입을 넣어서 표현하도록 개선
앞으로 적용해야할 사항