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

[#7] 선택 화면(장르 선택) 구현 #15

Merged
merged 12 commits into from
Feb 10, 2025
Merged

[#7] 선택 화면(장르 선택) 구현 #15

merged 12 commits into from
Feb 10, 2025

Conversation

NORIKIM
Copy link
Collaborator

@NORIKIM NORIKIM commented Jan 27, 2025

  • 장르 선택 화면(GenreView)을 구현하였습니다.
  • API 통신부, 이전 화면이동 버튼을 구현하였습니다.
  • 영화, 드라마 선택을 enum으로 수정였습니다.

@NORIKIM NORIKIM requested a review from abdul0986 January 28, 2025 01:06
@NORIKIM NORIKIM self-assigned this Jan 28, 2025
@NORIKIM NORIKIM added this to the 오늘뭐봄 milestone Jan 28, 2025
@NORIKIM NORIKIM linked an issue Jan 28, 2025 that may be closed by this pull request
4 tasks
Comment on lines 82 to 87
UserDefaults.standard.setValue(Content.movie.rawValue, forKey: UserdefaultKey.selectContent.rawValue)
self.tvButton.isSelected = false
self.tvButton.updateState()
self.movieButton.updateState()
} else {
self.selectedContent = self.tv
UserDefaults.standard.setValue(Content.tv.rawValue, forKey: UserdefaultKey.selectContent.rawValue)
Copy link

@abdul0986 abdul0986 Jan 28, 2025

Choose a reason for hiding this comment

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

func contentsSelectEvent(o1: FilterButton, o2: FilterButton) {
    ...
    o1.updateState()
    o2.isSelected = false
    o2.tvButton.updateState()
}

...

if sender == self.movieButton {
    contentsSelectEvent(self.movieButton, self.tvButton)
} else {
    contentsSelectEvent(self.tvButton, self.movieButton)
}

class GenreInteractor: GenreInteractorProtocol {
var presenter: GenrePresenterProtocol?

func fetchGenres() {

Choose a reason for hiding this comment

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

Suggested change
func fetchGenres() {
func fetchGenres(presenter: GenrePresenterProtocol?) {
}

Comment on lines +17 to +31
static func createGenreViewModule() -> GenreView {
let view = GenreView()
let presenter = GenrePresenter()
let router = GenreRouter()
let interactor = GenreInteractor()

view.presenter = presenter
presenter.router = router
presenter.interator = interactor
presenter.view = view
router.genreView = view
interactor.presenter = presenter

return view
}

Choose a reason for hiding this comment

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

Static Factory Method(A.K.A Class Factory) 패턴을 적용하신 이유가 궁금합니다.

}



Choose a reason for hiding this comment

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

//MARK 디렉터를 달아주시길 요청드립니다.



extension GenreView: GenreViewProtocol {
func makeGenreButton(_ genres: [Genre]) {

Choose a reason for hiding this comment

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

SRP를 준수할 수 있도록 리팩토링 부탁드립니다.


import Foundation

class Network {

Choose a reason for hiding this comment

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

Why not final class?

Comment on lines 11 to 15
private enum BaseUrl: String {
case movieGenre = "https://api.themoviedb.org/3/genre/movie/list"
case TVGenre = "https://api.themoviedb.org/3/genre/tv/list"
}

Choose a reason for hiding this comment

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

이 값들이 반드시 코드 안에 리터럴로 들어가 있어야 하는지 생각해봐주세요


import Foundation

class Network {

Choose a reason for hiding this comment

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

Network 클래스는 네트워크 통신에 관련된, 혹은 API 호출 스펙에 관련된 Infrastructure 레이어만 담당하도록 해주세요

Copy link

@abdul0986 abdul0986 left a comment

Choose a reason for hiding this comment

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

수정 부탁드립니다.

@NORIKIM
Copy link
Collaborator Author

NORIKIM commented Feb 4, 2025

피드백 반영하여 수정했습니다~

Copy link

@abdul0986 abdul0986 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 24 to 28
if let bodyParameters = try bodyParameters?.toDictionary() {
if !bodyParameters.isEmpty {
urlRequest.httpBody = try? JSONSerialization.data(withJSONObject: bodyParameters)
}
}

Choose a reason for hiding this comment

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

이 부분도 bodyParameters를 입력받아 urlRequest.httpBody를 리턴하는 함수로 분리 가능할 것 같습니다.

}

extension Requestable {
func getUrlRequest() throws -> URLRequest {

Choose a reason for hiding this comment

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

getUrlRequest()에서 너무 많은 일을 하고 있는 것은 아닌지 생각해봐주세요.

return urlRequest
}

func url() throws -> URL {

Choose a reason for hiding this comment

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

url() 함수도 좀더 작은 단위로 쪼갠다면 단일 책임 원칙을 훨씬 잘 준수할 수 있을 것 같습니다.

Comment on lines 40 to 60
if let error = error {
completion(.failure(error))
return
}

guard let response = response as? HTTPURLResponse else {
completion(.failure(NetworkError.unknownError))
return
}

guard (200 ... 299).contains(response.statusCode) else {
completion(.failure(NetworkError.invalidHttpStatusCode(response.statusCode)))
return
}

guard let data = data else {
completion(.failure(NetworkError.emptyData))
return
}

completion(.success((data)))

Choose a reason for hiding this comment

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

if와 guard 구문을 써서 return을 처리하셨는데요, 보통 guard 구문은 if 구문보다 먼저 사용되도록 구조를 잡는 것이 좋습니다.

  • 위와 같은 구성에서는 checkError() 하나가 너무 여러 타입의 처리를 담당하고 있는 듯 합니다. Overload 되도록 여러 타입으로 구성된 다양한 checkError()를 쪼개서 정의하는 게 어떨까요?

@NORIKIM
Copy link
Collaborator Author

NORIKIM commented Feb 9, 2025

피드백 재반영 하였습니다. 🙂

Copy link

@abdul0986 abdul0986 left a comment

Choose a reason for hiding this comment

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

LGTM

@NORIKIM NORIKIM merged commit a510735 into main Feb 10, 2025
2 checks passed
@NORIKIM NORIKIM deleted the feat/#7-genreView branch February 10, 2025 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

선택 화면(장르 선택) 구현
2 participants