[IDLE-119] HTTP요청을 위해 네트워크 모듈 설계및 구현 #6
Merged
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.
1. 관련된 이슈 및 소개
종류별로 API를 묶어내기 위해 BaseAPI로 API를 추상화 하였습니다.
구체 API타입을 Service에 전달하고 서비스의 요구사항과 합쳐저 구체 서비스 타입이됩니다.
해당 구조가 가지는 장점은 추상화된 API를 기점으로 서비스가 구체화 되어 특정 서비스에 사용될 API를 제한할 수 있습니다.
인증토큰들을 로컬에 저장하기위해 KeyValueStore로 저장소를 추상화하였습니다.
안정한 저장을 위해 KeyChain을 사용하기로 하였고 KeyChainAccess라이브러리를 사용하여 구체타입을 만들었습니다.
후에 다른 방법을 사용할 수도 있어 추상화하였습니다.
2. 변경된 점
NetworkInterface와 NetworkConcrete를 NetworkDataSoruce모듈로 합쳤습니다.
BaseAPI는 API베이스 주소같은 구체정보를 가지고 있는 추상타입입니다. BaseService역시 내부적으로 AF의 Adapter와 Retrier를 구현한 반 추상타입입니다. 모호한 타입들의 위치시키기 위해 새로운 모듈을 생성하기 보단 효율성을 위해 두 모듈을 합치는 방법을 선택했습니다.
4. 알게된 점
현재 DataSource에서 RxSwift를 사용하였습니다. Respository에도 사용될 것입니다. 이부분에서 도메인에도 효율성을 위해 RxSwift를 사용할 수 있지 않을까 생각하게 되었습니다. 해당 질문을 iOS멘토님께 드렸고 아래과 같은 점을 알게되었습니다.
RxSwift는 외부 프레임워크이고 도메인에서 사용시 클린 아키텍처에는 위배되지만 개발 효율이 올라간다는 점에서 충분이 도입가능하다고 생각하게되었습니다.
아키텍처보다 개발효율성이 우선될 수도 있습니다. 아키텍처에 너무 목메기보단 적절한 방법을 선택하는 것이 중요하다고 하셨습니다.