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

Step 4 - Jacob, Lina #31

Merged
merged 14 commits into from
Nov 14, 2020
Merged

Step 4 - Jacob, Lina #31

merged 14 commits into from
Nov 14, 2020

Conversation

KyungminLeeDev
Copy link

Step 4 : 주소 자동 변경

  • 사용자가 입력한 주소에 https://가 없다면 자동으로 붙여서 이동합니다.
  • 입력한 주소로 이동이 불가능하면 에러를 띄우도록 델리게이트로 구현했습니다.

Copy link
Member

@O-O-wl O-O-wl 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 +26
enum ErrorMessage: String {
case url = "입력한 주소가 올바른 형태가 아닙니다."
}
Copy link
Member

Choose a reason for hiding this comment

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

💥Error라는 프로토콜도 있으니 참고해보세요 🙇‍♂️

Copy link
Author

Choose a reason for hiding this comment

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

참고해서 다음 프로젝트에는 적용해보겠습니다! 감사합니다

Comment on lines 35 to 36
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)

// viewDidLoad()에서는 view가 아직 view hierarchy에 추가되지 않아서 alert을 present할 수 없다.
// viewDidApear()는 view가 view hierarchy에 추가된 후 호출되므로 alert을 present할 수 있다.
guard webView.load(favoriteWebPageURL: .google) else {
return showError(error: .url)
}
}

// MARK: - Types & IBActions & Methods
enum ErrorMessage: String {
case url = "입력한 주소가 올바른 형태가 아닙니다."
}

func showError(error: ErrorMessage) {
let errorAlert = UIAlertController(title: "Error!", message: error.rawValue, preferredStyle: .alert)
let ok = UIAlertAction(title: "확인", style: .default, handler: nil)
errorAlert.addAction(ok)

self.present(errorAlert, animated: false)
openPage(url: FavoriteWebPageURL.google.rawValue)
Copy link
Member

Choose a reason for hiding this comment

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

super.viewDidAppear()를 지우셨네요 혹시 어떤 이유가 있으실까요?
자식클래스는 부모클래스의 동작을 대치하는 것이 아니라 확장하는 형태 여야 할 것 같아요.
👨‍👩‍👧

Choose a reason for hiding this comment

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

헙.. 제가 작업하다가 삭제한거같아요ㅠㅠ 수정하겠습니다!!!

Comment on lines +84 to +88
func addHttpsFront(of url: String) -> String {
return "https://" + url
}

func checkFront(of url: String?) -> Bool {
Copy link
Member

Choose a reason for hiding this comment

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

메서드들이 정의되는 순서도 의도를 내포할 수 있습니다.
혹시 메서드의 정의 순서를 어떤 기준으로 매기고 계신가요? 😉

Choose a reason for hiding this comment

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

이번에 리팩토링하면서 함께 고민했던 부분인데요!
원래는 openPage와 showError부분이 viewDidAppear 밑에 순서대로 나오고,
나머지는 같은 순서였어요.
그런데 이번에 리팩토링 과정에서 IBAction은 이것들 끼리, 나머지 메소드들이 메소드들끼리 함께 묶여있는게 더 보기 좋을 것 같아서 밑으로 내려봤어요!
혹시 두 메소드가 다시 위쪽에 위치하는게 가독성에 더 좋을까요?

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 65 to 67
guard !webView.isLoading else {
return
}
Copy link
Member

Choose a reason for hiding this comment

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

궁금한 것이 있습니다 🙋‍♂️
webView가 _www.naver.com_를 요청하고 로딩 중에
www.yagom.net 을 입력하면 뒤에 요청된 www.yagom.net 이 무시되야하나요?

Copy link
Author

Choose a reason for hiding this comment

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

현재 로직상으로는 무시됩니다.
이 부분을 추가한건 로딩중에 사용자가 이동 버튼을 중복되서 계속 누르는 경우를 방지하고자 한 것인데,
또 다른 문제를 생각하지 못한 것 같습니다.
만약 인터넷 속도가 매우 느린 상황이라면 로딩이 느릴것이고,
유저는 다른 페이지로 이동하고 싶지만 버튼을 눌러도 이동하지 못하는 상황이 발생할 것 입니다.
이 부분에 대한 보완 방법은 다시 생각해보겠습니다.

Copy link
Member

@O-O-wl O-O-wl Nov 13, 2020

Choose a reason for hiding this comment

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

로딩중에 사용자가 이동 버튼을 중복되서 계속 누르는 경우를 방지하고자 한 것

이런 케이스를 미리 감안하시다니 멋지네요!
👍

Comment on lines 18 to 21
enum FavoriteWebPageURL: String {
case google = "https://www.google.com/"
case yagomDotNet = "https://yagom.net/"
case naver = "https://www.naver.com/"
Copy link
Member

Choose a reason for hiding this comment

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

enum을 이용해서 구현하신 이유가 있을까요? 😉
case 자체로보다는 rawValue를 위해 만들어진 타입 같아서 여쭤봅니답

Copy link
Author

Choose a reason for hiding this comment

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

즐겨찾는 페이지가 1개가 아니라 추가될 수도 있다고 생각하고 사용했습니다.
원래는 즐겨찾는 페이지 enum값을 받아서 이동하는 메서드가 있었지만,
리팩토링 과정에서 삭제하게 되서 현재 enum이 rawValue 참조로만 쓰이게 되었습니다.

Copy link
Member

Choose a reason for hiding this comment

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

아하 그런 히스토리가 있었군요
스펙이 바뀌었다면 코드도 같이 변경되도 좋을 것 같아요😉

@KyungminLeeDev
Copy link
Author

@O-O-wl 리뷰해주신 내용 수정했습니다! 다시 코드 리뷰와 머지 부탁드려요 ㅎㅎ

@O-O-wl
Copy link
Member

O-O-wl commented Nov 14, 2020

고생하셨습니다 제이콥, 리나!
다음스탭도 화이팅!👍

@O-O-wl O-O-wl merged commit a842933 into yagom-academy:1-jacob Nov 14, 2020
@KyungminLeeDev KyungminLeeDev deleted the step-4 branch November 15, 2020 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants