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 1] garden #12

Open
wants to merge 7 commits into
base: rft_1_garden
Choose a base branch
from

Conversation

gadisom
Copy link

@gadisom gadisom commented Feb 4, 2024

안녕하세요 !! @havilog

고민했던 점

데이터를 불러오는 부분을 따로 분리하면 좋을 것 같다고 생각해 네트워크 전용 클래스를 만들었습니다.
weather , city , tempunit 를 현재는 각자 따로 받아오고 있는데 한번에 전부 보내서 하위 모듈에서 수정하는게 나은지 상위 모듈에서 3개를 분리해주는게 나은지 고민입니다.

label 이나 image 를 전역으로 설정했는데 이 부분 피드백 부탁드려요 !

Copy link

@havilog havilog left a comment

Choose a reason for hiding this comment

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

코멘트에 고민하신 부분들 관련하여 생각할 포인트 작성해놨으니 확인 바랍니다!

WeatherForecast/WeatherForecast/NetworkService.swift Outdated Show resolved Hide resolved
WeatherForecast/WeatherForecast/NetworkService.swift Outdated Show resolved Hide resolved
WeatherForecast/WeatherForecast/ViewController.swift Outdated Show resolved Hide resolved
WeatherForecast/WeatherForecast/ViewController.swift Outdated Show resolved Hide resolved
WeatherForecast/WeatherForecast/NetworkService.swift Outdated Show resolved Hide resolved
WeatherForecast/WeatherForecast/WeatherTableViewCell.swift Outdated Show resolved Hide resolved
WeatherForecast/WeatherForecast/WeatherTableViewCell.swift Outdated Show resolved Hide resolved
WeatherForecast/WeatherForecast/WeatherTableViewCell.swift Outdated Show resolved Hide resolved
Copy link

@havilog havilog left a comment

Choose a reason for hiding this comment

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

추가 코멘트 확인해주세요 가든!

WeatherForecast/WeatherForecast/InfoModel.swift Outdated Show resolved Hide resolved
WeatherForecast/WeatherForecast/InfoModel.swift Outdated Show resolved Hide resolved
Comment on lines 50 to 71
class ImageCacheManager {
static let shared = ImageCacheManager() // 싱글턴 인스턴스
private var imageCache: NSCache<NSString, UIImage> = NSCache()

func cacheImage(_ image: UIImage, forKey key: String) {
imageCache.setObject(image, forKey: key as NSString)
log("Image cached for key: \(key)")
}

func getImage(forKey key: String) -> UIImage? {
if let cachedImage = imageCache.object(forKey: key as NSString) {
log("Returning cached image for key: \(key)")
return cachedImage
}
log("No cached image : \(key)")
return nil
}

private func log(_ message: String) {
print(message)
}
}
Copy link

Choose a reason for hiding this comment

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

  1. 상속이 안되는 class의 경우 final을 default로 붙여주세요!
  2. imageCache는 let이어도 될 것 같아요!
  3. 디스크 캐시가 생길수도 있을거 같아서 protocol로 캐시할 수 있는 기능을 추상화 해보는것도 좋을 것 같아요

// Created by 김정원 on 2/4/24.
//
import UIKit
final class TransforJSON {
Copy link

Choose a reason for hiding this comment

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

  1. JSON을 가져오는 기능과, 이미지를 가져오는 기능은 분리되면 좋을 것 같아요
  2. jsonDecoder를 파라미터로 주입받아서 확장성을 키워보는것도 좋을 것 같아요
  3. fetch�Json<T: Decodable>() throws -> T 와 같이 작성한다면, 디코딩에서의 에러도 받을 수 있고 여러가지 json을 디코딩 할 수 있을것 같아요

WeatherForecast/WeatherForecast/WeatherTableViewCell.swift Outdated Show resolved Hide resolved
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