Skip to content

Conversation

@Naknakk
Copy link
Contributor

@Naknakk Naknakk commented Feb 3, 2024

⭐️Issue

#111

🌟Motivation

  • RegisterNormalView를 Refactor 했습니당.

🌟Key Changes

멘토님 피드백을 바탕으로 수정했으며, 중복된 코드 제거, UIView에 들어있던 비즈니스 로직 ViewController로 이동 등의 변화가 있습니다.

  • 멘토님 피드백 기반

    • 등록/수정 완료 버튼에 throttle 추가로 연타 방지
    • Service에서 사용한 강제 try! 문을 do-catch로 에러처리 해주었습니다.
    • 매직넘버 줄이기(완전히 다 없애진 못했습니당.. 너무 자잘하고 당연한 것들로 보여서 굳이 없애지 않아도 되나..? 하는 것들이 남아있어서 고민입니당.)
    • 접근 제어자 수정
    • URL 처리시 직접 문자열을 작성하는 부분을 없애고, 메서드를 통해 받아오도록 하였습니다.
    • 고차함수를 활용하여, for + append 에서 map으로 변경하였습니다.
  • 함께 회의했던 것들 기반

    • MARK 주석 양식 변경에 따른 메서드 분리 및 위치 정리를 했습니다.
    • 특히 RxSwift 부분에서 Input / Output / Navigation 세가지로 분류하기 위해 노력했습니다. (곰튀김님이 세가지로 분류하셨길래 참고했습니당.)
    • UIViewController+ 파일에 VC간 이동 함수를 추가하여, 화면 이동 함수를 깔끔하게 작성할 수 있었습니다.
  • 개인적으로 아쉬웠던 부분들

    • View Depth가 너무 깊어 직관적이지 못하다고 판단해, 다시 몇몇 View를 합쳐 Depth를 줄였습니다.
    • DataPickerView에 들어있던 비즈니스 로직을 ViewController로 최대한 옮겼습니다.
    • platformList 데이터가 View에 있던 것을 ViewController로 옮겼습니다.
    • ViewController에서 급하게 작성하느라 중복된 코드를 최소화 하였습니다.
    • RxSwift 순환 참조 방지를 위해 모든 구독 함수 (subscribe, bind, drive)를 with: self , onNext: 로 바꾸었습니다.
    • UI관련된 부분은 모두 Relay + Driver를 통해 메인스레드 작동&에러 무시 처리를 하였습니다.

🌟Simulation

  • 동작이 달라진 부분은 없습니다.

🌟To Reviewer

  • 접근 제어자를 멘토님이 필요에 따라 private(set)으로 바꾸는게 어떠냐 하셨는데, private(set)의 경우 var로만 선언할 수 있어, 해당 클래스 내에서 변수로 선언해야만 합니다. 근데 UI Components의 경우 내부든 외부든 바꿀일이 없어 상수로 선언하고 싶었기 때문에.. 그냥 internal(기본) let으로 선언하였습니다.
  • 코드를 전체적으로 옮기고 하는 일이 잦아서 변경사항이 굉장히 많아졌기 때문에.... 추가 기능 구현 이전에 리팩토링 한 것만 PR 우선 올립니다.
  • 팩토리 패턴은 아래와 같이 적용할 수 있을 것 같은데, ModuleFactory 클래스를 어느 폴더에 작성해야할지 고민입니다. 어디에 만드는게 좋을까요?!? 일단 제 생각으로는 Resource 폴더 내에 Factory 폴더를 만들어도 좋을 것 같습니다..!
스크린샷 2024-02-03 22 34 54

🌟To do

  • 밀어서 뒤로가기 기능은 지원이 PR이 머지된 이후에 추가하겠습니당.

🌟Reference


@Naknakk Naknakk changed the title Fix/#111 register view [Refactor] #111 - RegisterNormalView Refactor Feb 3, 2024
@Naknakk Naknakk self-assigned this Feb 3, 2024
@Naknakk Naknakk marked this pull request as ready for review February 3, 2024 13:47
Copy link
Member

@Guryss Guryss left a comment

Choose a reason for hiding this comment

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

수고하셨서용!!!! 굿뜨

VC보니까 Input, Output 구분 되게 잘해놓으신거 같더라구요??
제가 지금 그 부분에서 어려움을 겪고 있어서 ....,,, 제 코드 보고 리뷰 남겨주십쇼 참고로 Input으로 어떻게 빼야할지 모르겠음 ㅠㅠ

Comment on lines +45 to +62
func getNovelInfo(novelId: Int) -> Single<NovelResult> {
do {
let request = try makeHTTPRequest(method: .get,
path: URLs.Novel.getNovelInfo(novelId: novelId),
headers: APIConstants.testTokenHeader,
body: nil)

NetworkLogger.log(request: request)

return urlSession.rx.data(request: request)
.map {NovelResult(
newNovelResult: try? JSONDecoder().decode(NewNovelResult.self, from: $0),
editNovelResult: try? JSONDecoder().decode(EditNovelResult.self, from: $0))
}
.asSingle()
} catch {
return Single.error(error)
}
Copy link
Member

Choose a reason for hiding this comment

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

W3;
do-catch 사용 굿굿!!! 나두 이렇게 처리했다능 !!!

Copy link
Member

Choose a reason for hiding this comment

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

W3

Copy link
Collaborator

Choose a reason for hiding this comment

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

우왕굿!

Comment on lines +30 to +35
static func postUserNovel(novelId: Int) -> String {
return "/user-novels/\(novelId)"
}
static func patchUserNovel(userNovelId: Int) -> String {
return "/user-novels/\(userNovelId)"
}
Copy link
Member

Choose a reason for hiding this comment

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

👍

Comment on lines 77 to 78

private func setHieararchy() {
Copy link
Member

Choose a reason for hiding this comment

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

W1;
setHierarchy 같은데!!! 오타난듯하오 수정해주셍요~

Copy link
Contributor Author

Choose a reason for hiding this comment

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

대박이다 이걸 어떻게 발견했지 고마워용!!!

Copy link
Member

@ena-isme ena-isme left a comment

Choose a reason for hiding this comment

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

좋아요 깔꼼하네용

Comment on lines +45 to +62
func getNovelInfo(novelId: Int) -> Single<NovelResult> {
do {
let request = try makeHTTPRequest(method: .get,
path: URLs.Novel.getNovelInfo(novelId: novelId),
headers: APIConstants.testTokenHeader,
body: nil)

NetworkLogger.log(request: request)

return urlSession.rx.data(request: request)
.map {NovelResult(
newNovelResult: try? JSONDecoder().decode(NewNovelResult.self, from: $0),
editNovelResult: try? JSONDecoder().decode(EditNovelResult.self, from: $0))
}
.asSingle()
} catch {
return Single.error(error)
}
Copy link
Member

Choose a reason for hiding this comment

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

W3

Copy link
Collaborator

@hyowon612 hyowon612 left a comment

Choose a reason for hiding this comment

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

대박이네예 완젼 짱짱 수고했삼👍
쇽쇽샥샥.. 열시미 해볼게요 ㅋ 👼🏻

Comment on lines +45 to +62
func getNovelInfo(novelId: Int) -> Single<NovelResult> {
do {
let request = try makeHTTPRequest(method: .get,
path: URLs.Novel.getNovelInfo(novelId: novelId),
headers: APIConstants.testTokenHeader,
body: nil)

NetworkLogger.log(request: request)

return urlSession.rx.data(request: request)
.map {NovelResult(
newNovelResult: try? JSONDecoder().decode(NewNovelResult.self, from: $0),
editNovelResult: try? JSONDecoder().decode(EditNovelResult.self, from: $0))
}
.asSingle()
} catch {
return Single.error(error)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

우왕굿!

animated: true)
}

func moveToNovelDetailVC(userNovelId: Int) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

W3
VC로 통일하자구 했던가용? 컨벤션에는 약어 사용하지 말라구 했던거로 기억해서!!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

아고 넵 약어 사용 빼겠습니다~~

@Naknakk Naknakk merged commit f042791 into main Feb 9, 2024
@Naknakk Naknakk deleted the Fix/#111-RegisterView branch February 12, 2024 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants