-
Notifications
You must be signed in to change notification settings - Fork 1
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
[Refactor/#427] BrowseWorkbooksUseCase 리펙토링 #428
Conversation
open class WorkBooks( | ||
private val workbooks: List<WorkBook>, | ||
) { |
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.
WorkBook 리스트로 생성하는 WorkBooks 모델을 추가하였습니다.
해당 모델로는 WorkBook 리스트를 조회할 조회할 수 없도록 private val로 선언하였습니다.
fun order(delegator: WorkbookOrderDelegator): OrderedWorkBooks { | ||
return delegator.order(workbooks) | ||
} |
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.
정렬시에는 Workbooks가 가지고 있는 Workbook 리스트와 비교할 데이터가 필요할 수 있다고 생각하였습니다.
그래서 WorkbookOrderDelegator를 생성할 때 비교할 데이터와 함께 생성하고 order 메서드에는 Workbooks가 가지고 있는 Workbook 리스트 넘겨 정렬된 워크북(OrderedWorkbooks)을 반환받을 수 있도록 하였습니다.
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.
아 저도 코멘트 달면서 생각하는 것을 제대로 전달 할 수 있을까 생각했던 것 같아요
남겨주신 코멘트 반영해서 추가 수정한 이후에 별도의 글 + 그림으로 쭉 설명하는 것을 추가할께요!
* @param workbooks 정렬할 워크북 목록 | ||
* @return 정렬된 워크북 목록 | ||
*/ | ||
fun order(workbooks: List<WorkBook>): OrderedWorkBooks |
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.
WorkbookDelegator의 order 메서드에선 비교 원본을 파라미터로 받고 정렬후 OrderedWorkBooks를 반환합니다.
class OrderedWorkBooks( | ||
val workbooks: List<WorkBook>, | ||
) : WorkBooks(workbooks) |
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.
정렬이 완료된 Workbook 리스트가 있는 OrderedWorkBooks은 workbooks를 노출합니다.
WorkBooks는 workbooks를 노출하지 않는다.
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.
이미 정렬된 상태라는걸 의미할 수 있게 workbooks 변수명 수정하는것도 좋을거 같아요
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.
OrderedWorkBooks
가 WorkBooks
를 상속하는데, OrderedWorkBooks
는 이미 정렬이 되어 있는애들이기 때문에, 얘에 대해 order
메소드를 실행하면 어떻게 되나요?
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.
음.. 구현 당시에는 OrderedWorkBooks
도 다시 정렬해도 괜찮을 것이라 생각했는데 조금 더 분리하는 방법을 고민해 볼께요!
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.
OrderedWorkBooks
가WorkBooks
를 상속하는데,OrderedWorkBooks
는 이미 정렬이 되어 있는애들이기 때문에, 얘에 대해order
메소드를 실행하면 어떻게 되나요?
이번 구현에 정렬되지 않은 상태의 클래스만 정렬을 수행할 수 있도록 수정하였습니다.
subscriptionCount = record.subscriptionCount | ||
) | ||
} | ||
val workbooks = toWorkbooks(workbookRecords, writerRecords) |
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.
값들을 단순 조합해서 새로운 객체(Workbook, Workbooks)를 만들기에 toWorkbooks라 네이밍하였습니다.
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.
해당 변환 과정을 UC에서 하는게 아니라 WorkBooks 모델 자체에서 제공해주는건 어떤가요
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.
컨버터를 만들어서 할 수 있을 것 같은데
저희가 부분적으로 모델을 사용하고 있어서 우선 메서드를 선택했어요
추후 모델이 조금 더 많아지면 도입하는게 어떤가요?
} | ||
|
||
val orderedWorkbooks = when (orderStrategy) { | ||
val orderStrategy = getOrderStrategy(useCaseIn) |
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.
useCaseIn의 값을 가지고 단순 판단만 들어가 getOrderStrategy라 네이밍 하였습니다.
}.let { delegator -> | ||
workbookOrderDelegatorExecutor.execute(delegator) | ||
else -> genBasicWorkbookOrderDelegator() | ||
} | ||
|
||
orderedWorkbooks.map { workBook -> | ||
val orderedWorkbooks = workbooks.order(orderDelegator) |
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.
이전과 다르게 workbooks 객체에 workbookOrderDelegator를 넘기고
workbooks 객체가 order을 진행한 이후 orderedworkbooks 객체를 반환받습니다.
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.
수고많으십니다
private fun toWorkbooks( | ||
workbookRecords: List<SelectWorkBookRecordWithSubscriptionCount>, | ||
writerRecords: Map<Long, List<WriterMappedWorkbookOutDto>>, |
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.
SelectWorkBookRecordWithSubscriptionCount -> 디비에서 조회된 결과를 record로 끝나기로 약속되어 있는데 네이밍이 약간 어색해보임.
writerRecords -> 실제 받는 타입이 레코드가 아닌데 변수명은 왜 record인지?
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.
디비에서 조회된 결과를 record로 끝나기로 약속되어 있는데 네이밍이 약간 어색해보임.
다시보니 파라미터로 받는 둘다 디비에서 조회된 결과를 받는 것이라 record로 해도 괜찮을 것 같은데
혹시 다른 적절한 파라미터 네이밍 있을까요?
subscriptionCount = record.subscriptionCount | ||
) | ||
} | ||
val workbooks = toWorkbooks(workbookRecords, writerRecords) |
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.
해당 변환 과정을 UC에서 하는게 아니라 WorkBooks 모델 자체에서 제공해주는건 어떤가요
}.let { delegator -> | ||
workbookOrderDelegatorExecutor.execute(delegator) | ||
else -> genBasicWorkbookOrderDelegator() | ||
} | ||
|
||
orderedWorkbooks.map { workBook -> | ||
val orderedWorkbooks = workbooks.order(orderDelegator) |
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.
넵 모델 자체적으로 진행하는게 좋아보이네요
class OrderedWorkBooks( | ||
val workbooks: List<WorkBook>, | ||
) : WorkBooks(workbooks) |
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.
이미 정렬된 상태라는걸 의미할 수 있게 workbooks 변수명 수정하는것도 좋을거 같아요
fun order(delegator: WorkbookOrderDelegator): OrderedWorkBooks { | ||
return delegator.order(workbooks) | ||
} |
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.
이해몬함..
class OrderedWorkBooks( | ||
val workbooks: List<WorkBook>, | ||
) : WorkBooks(workbooks) |
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.
OrderedWorkBooks
가 WorkBooks
를 상속하는데, OrderedWorkBooks
는 이미 정렬이 되어 있는애들이기 때문에, 얘에 대해 order
메소드를 실행하면 어떻게 되나요?
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.
리뷰 감사합니다.
추가 리펙한 한 이후에 다시 리뷰 요청해볼께요!
subscriptionCount = record.subscriptionCount | ||
) | ||
} | ||
val workbooks = toWorkbooks(workbookRecords, writerRecords) |
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.
컨버터를 만들어서 할 수 있을 것 같은데
저희가 부분적으로 모델을 사용하고 있어서 우선 메서드를 선택했어요
추후 모델이 조금 더 많아지면 도입하는게 어떤가요?
private fun toWorkbooks( | ||
workbookRecords: List<SelectWorkBookRecordWithSubscriptionCount>, | ||
writerRecords: Map<Long, List<WriterMappedWorkbookOutDto>>, |
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.
요 부분은 인텔리 자동완성에 너무 의지한 것 같네요..!
적절한 네이밍은 고민해볼께요!
class OrderedWorkBooks( | ||
val workbooks: List<WorkBook>, | ||
) : WorkBooks(workbooks) |
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.
음.. 구현 당시에는 OrderedWorkBooks
도 다시 정렬해도 괜찮을 것이라 생각했는데 조금 더 분리하는 방법을 고민해 볼께요!
fun order(delegator: WorkbookOrderDelegator): OrderedWorkBooks { | ||
return delegator.order(workbooks) | ||
} |
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.
아 저도 코멘트 달면서 생각하는 것을 제대로 전달 할 수 있을까 생각했던 것 같아요
남겨주신 코멘트 반영해서 추가 수정한 이후에 별도의 글 + 그림으로 쭉 설명하는 것을 추가할께요!
useCaseIn.viewCategory == ViewCategory.MAIN_CARD && useCaseIn.memberId == null -> WorkBookOrderStrategy.MAIN_VIEW_UNAUTH | ||
else -> WorkBookOrderStrategy.BASIC | ||
} | ||
val workbooks = toWorkbooks(workbookRecords, writerRecords) |
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.
우선 workbooks 데이터로 만듭니다.
) | ||
}.let { subscribedWorkbooks -> | ||
AuthMainViewWorkbookOrderDelegator(workbookDetails, subscribedWorkbooks) | ||
val orderedWorkbook = OrderTargetWorkBooks(workbooks).let { target -> |
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.
order 모델에서 사용할 OrderTargetWorkBooks로 변환합니다.
orderDelegator | ||
?.let { delegator -> | ||
UnOrderedWorkBooks( | ||
target, | ||
delegator | ||
).order().orderedWorkbooks | ||
} |
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.
orderDelegator가 있으면 변환할 필요가 있다고 판단하고 UnOrderedWorkBooks를 만든 이후 정렬합니다.
orderDelegator | ||
?.let { delegator -> | ||
UnOrderedWorkBooks( | ||
target, | ||
delegator | ||
).order() | ||
} |
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.
orderDelegator 가 존재한다면 정렬 되어있지 않다고 판단하고 UnOrderedWorkBooks를 생성한 후 정렬하여 OrderedWorkBooks를 반환합니다.
}.let { delegator -> | ||
workbookOrderDelegatorExecutor.execute(delegator) | ||
} | ||
?: run { OrderedWorkBooks(target) } |
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.
orderDelegator 가 존재하지 않는다면 정렬된 상태라 판단하고 바로 OrderedWorkBooks를 반환합니다.
🎫 연관 이슈
resolved: #427
💁♂️ PR 내용
🙏 작업
🙈 PR 참고 사항
📸 스크린샷
🤖 테스트 체크리스트