[Refactor 1.0.5] Storage 기능 분리 #198
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
현재 SwiftLint 제약으로 인해 빌드가 제대로 되지 않는 상황인데,
우선 상황 공유를 위해 PR을 보냅니다.
이전에 논의한 대로 StorageType의 인터페이스를 역할에 나누었습니다.
나눈 인터페이스는 아래와 같은 5가지입니다.
(나눈 방식이 적당한 지도 확인 부탁드립니다!)
필요한 인터페이스만을 가지고 있게 하기 위해서
기존 모든 인터페이스를 포괄하는 StorageType 객체를 가지고 있던 superclass CommonViewModel에서 Storage 프로퍼티를 제거하고,
각 ViewModel subclass에서 필요한 인터페이스만 가지고 있도록 변경하였습니다.
그런데 현재 ViewModel을 주입해주는 곳이 직전 Scene의 ViewModel이다 보니,
주입을 받는 객체에 필요한 인터페이스가 주입 시작 객체에 선언되어 있지 않으면 강제로 타입캐스팅을 해야하는 문제가 발생하고 이로 인해 Lint 오류가 발생합니다.
물론 무시하는 방법도 있겠지만, 전혀 안전하지 않은 방법이므로 피하려고 합니다.
이를 개선하기 위한 방법으로,
ViewModel을 일괄적으로 생성해주는 팩토리가 개별적으로 존재한다면 모든 인터페이스를 채택하고 있는 Storage를 이미 가지고 있는 상태에서 각 ViewModel에 뿌려줄 수 있어서 강제 타입 캐스팅을 하지 않아도 될 것으로 보입니다.
이 부분에 대해서 의견을 구하고자 우선 PR을 올리니 시간 되실 때 한번 검토 부탁드려요!