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

[FIX] 빵집 상세보기 리팩터링 #145

Merged
merged 4 commits into from
Aug 14, 2023
Merged

[FIX] 빵집 상세보기 리팩터링 #145

merged 4 commits into from
Aug 14, 2023

Conversation

sung-silver
Copy link
Member

🍞 PR 타입

  • 기능 추가
  • 기능 수정
  • 기능 삭제
  • 버그 수정
  • 의존성, 환경 변수, 빌드 관련 코드 업데이트

🍞 반영 브랜치

🍞 변경 사항

  • Mapper를 이용하여 리팩토링 실시했습니다
  • 빵집 상세보기 ResponseDTO에서 운영시간에 대한 필드 이름이 엔티티와 다른 것을 확인하고 엔티티에 맞춰 "openingHours"로 변경했습니다

🍞 테스트 결과

image

🍞 To Reviewer

  • 단순 매개변수 전달을 위한 변수 선언에 대해 어떻게 생각하시는지 궁금합니다!

@@ -79,10 +79,10 @@ public BakeryDetailResponseDTO getBakeryDetail(Long memberId, Long bakeryId) {
bakeryRepository
.findById(bakeryId)
.orElseThrow(() -> new NotFoundException(ErrorType.NOT_FOUND_BAKERY_EXCEPTION));
List<Menu> bakeryMenu = menuRepository.findAllByBakery(bakery);
Copy link
Collaborator

Choose a reason for hiding this comment

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

매개변수 전달만을 위한 변수 선언
-> 변수를 선언한 코드가 더 가독성이 좋다면 변수 선언 하고 매개변수로 전달하는게 좋다고 생각합니다
getXXX() 이런식으로 값을 얻어오는 메서드의 경우 별다른 변수 선언 없이 바로 매개변수에 넣어줘도 가독성이 크게 나빠지지는 않는다고 생각해요~ 현재 코드로 봤을 땐 변경 전 코드가 (제기준) 더 좋아보이긴 합니다

Copy link
Member Author

Choose a reason for hiding this comment

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

참고하겠습니다 감사티비!!

@@ -81,7 +82,7 @@ public BakeryDetailResponseDTO getBakeryDetail(Long memberId, Long bakeryId) {
List<Menu> bakeryMenu = menuRepository.findAllByBakery(bakery);
BreadTypeResponseDTO breadType = getBreadType(bakery);
boolean isBookMarked = isBookMarked(memberId, bakeryId);
List<MenuResponseDTO> menuList = new ArrayList<>();
List<MenuResponseDTO> menuList = MenuMapper.INSTANCE.toMenuResponseDTOList(bakeryMenu);
String address =
bakery.getState()
+ " "
Copy link
Collaborator

Choose a reason for hiding this comment

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

요거 띄어쓰기 BLANK_SPACE 이런 식으로 상수화 처리 어떠실까욜

Copy link
Collaborator

Choose a reason for hiding this comment

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

추가로 address 가져오는 부분 함수로 빼는건 어떠실까욜 매개변수가 너무 많을까요??

Copy link
Member Author

Choose a reason for hiding this comment

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

오옹 상수화는 생각도 못했네요 좋습니다! address 가져오는 부분도 함수로 빼는거 좋습니다!

.phoneNumber(bakery.getPhoneNumber())
.menuList(menuList)
.build();
return BakeryMapper.INSTANCE.toBakeryDetailResponseDTO(
Copy link
Collaborator

Choose a reason for hiding this comment

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

휴우 깔끔하네요~ 마음의 안정

@@ -82,6 +82,14 @@ public BakeryDetailResponseDTO getBakeryDetail(Long memberId, Long bakeryId) {
BreadTypeResponseDTO breadType = getBreadType(bakery);
Copy link
Collaborator

Choose a reason for hiding this comment

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

BreadTypeResponseDTO로 변환하는 매퍼 만들었던걸로 기억하는데 있으면 매퍼로 처리하는것도 괜찮아 보입니다~

Copy link
Member Author

Choose a reason for hiding this comment

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

매퍼로 동일하게 처리하고 리팩토링하면서 다른 곳에서 쓰이면 같이 수정하겠습니다~

Copy link
Collaborator

Choose a reason for hiding this comment

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

제가 이미 쓰긴합니다 하암ㅋㅋ 매퍼 코드 있으니 함 생각해보세요~

+ " "
+ bakery.getTown()
+ " "
+ bakery.getAddressRest();

for (Menu menu : bakeryMenu) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

메뉴 리스트 가져오는 것도 함수로 빼도 괜찮을 것 같습니다~

Copy link
Member Author

Choose a reason for hiding this comment

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

가장 최근 commit에 이친구도 Mapper로 처리했습니다 !!

Copy link
Collaborator

Choose a reason for hiding this comment

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

굿 좋습니다~

@sung-silver sung-silver merged commit f7bdd74 into dev Aug 14, 2023
1 check passed
@sung-silver sung-silver deleted the fix/#143 branch February 25, 2024 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FIX] 빵집 상세보기 API 리팩터링
2 participants