-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
NORIKIM
commented
Jan 27, 2025
- 장르 선택 화면(GenreView)을 구현하였습니다.
- API 통신부, 이전 화면이동 버튼을 구현하였습니다.
- 영화, 드라마 선택을 enum으로 수정였습니다.
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) |
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.
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() { |
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.
func fetchGenres() { | |
func fetchGenres(presenter: GenrePresenterProtocol?) { | |
} |
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 | ||
} |
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.
Static Factory Method(A.K.A Class Factory)
패턴을 적용하신 이유가 궁금합니다.
} | ||
|
||
|
||
|
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.
//MARK
디렉터를 달아주시길 요청드립니다.
|
||
|
||
extension GenreView: GenreViewProtocol { | ||
func makeGenreButton(_ genres: [Genre]) { |
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.
SRP를 준수할 수 있도록 리팩토링 부탁드립니다.
|
||
import Foundation | ||
|
||
class Network { |
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.
Why not final
class?
private enum BaseUrl: String { | ||
case movieGenre = "https://api.themoviedb.org/3/genre/movie/list" | ||
case TVGenre = "https://api.themoviedb.org/3/genre/tv/list" | ||
} | ||
|
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.
이 값들이 반드시 코드 안에 리터럴로 들어가 있어야 하는지 생각해봐주세요
|
||
import Foundation | ||
|
||
class Network { |
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.
Network 클래스는 네트워크 통신에 관련된, 혹은 API 호출 스펙에 관련된 Infrastructure 레이어만 담당하도록 해주세요
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.
수정 부탁드립니다.
7e31dfe
to
10c8929
Compare
10c8929
to
a0dd928
Compare
피드백 반영하여 수정했습니다~ |
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.
추가 수정 요청 사항이 있습니다. 확인 부탁드립니다.
if let bodyParameters = try bodyParameters?.toDictionary() { | ||
if !bodyParameters.isEmpty { | ||
urlRequest.httpBody = try? JSONSerialization.data(withJSONObject: bodyParameters) | ||
} | ||
} |
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.
이 부분도 bodyParameters를 입력받아 urlRequest.httpBody를 리턴하는 함수로 분리 가능할 것 같습니다.
} | ||
|
||
extension Requestable { | ||
func getUrlRequest() throws -> URLRequest { |
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.
getUrlRequest()에서 너무 많은 일을 하고 있는 것은 아닌지 생각해봐주세요.
return urlRequest | ||
} | ||
|
||
func url() throws -> URL { |
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.
url()
함수도 좀더 작은 단위로 쪼갠다면 단일 책임 원칙을 훨씬 잘 준수할 수 있을 것 같습니다.
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))) |
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.
if와 guard 구문을 써서 return을 처리하셨는데요, 보통 guard 구문은 if 구문보다 먼저 사용되도록 구조를 잡는 것이 좋습니다.
- 위와 같은 구성에서는 checkError() 하나가 너무 여러 타입의 처리를 담당하고 있는 듯 합니다. Overload 되도록 여러 타입으로 구성된 다양한 checkError()를 쪼개서 정의하는 게 어떨까요?
피드백 재반영 하였습니다. 🙂 |
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.
LGTM
|