[장바구니 리팩토링 Homework: Layered Architecture] 라바(고제성) 과제 제출합니다. - #12
Open
kojesung wants to merge 2 commits into
Open
[장바구니 리팩토링 Homework: Layered Architecture] 라바(고제성) 과제 제출합니다.#12kojesung wants to merge 2 commits into
kojesung wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
처음엔 "API 호출 방식이 변경되는 모든 경우에 대응"하기 위해 Repository 패턴을 선택했습니다. 하지만 리팩토링 결과를 보니 오히려 React 생태계에서 흔히 쓰는
apiInstance방식보다 변화에 대응하기 어려워 보이는 부분이 있었습니다.(fetch -> axios로 변경되면 모든 엔드포인트별로 메서드를 다시 만들어줘야 했음)fetch -> axios와 같은 변경 형태와 처음 리팩토링한 Repository 패턴이 대응할 수 있는 변경 형태가 다루는 변경 관점이 다르다는 걸 인지하지 못했기 때문에 발생한 시행착오였다고 생각합니다
fetch -> axios와 같은 형태의 교체는 HTTP라는 전제가 깔려있는 상태인데 Repository가 이 기준점까지 담당하게 된다면 AxiosProductRepository와 같은 구현을 별도로 작성해야 하고 도메인 메서드를 통째로 다시 구현하게 됩니다.
이에 대한 해결 방법으로
HttpClient 인터페이스를 한 계층을 추가하여 분리했습니다.
결과적으로 HttpClient 인터페이스가 apiInstance와 동일한 효과를 내면서, Repository 패턴의 본래 역할이었던 저장소 구현 교체도 함께 커버하는 구조가 되는 것을 의도했습니다.