[장바구니 리팩토링 Homework: Layered Architecture] 찰리(김상윤) 과제 제출합니다. - #2
Open
yuncic wants to merge 1 commit into
Open
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.
리팩토링 내용
기존에
ProductSection.tsx한 파일에 몰려있던 로직을 역할 단위로 분리했습니다.각 파일의 책임
domain/product.ts: Product 타입 정의, isValidName / isValidPrice 도메인 검증 규칙api/productApi.ts: 서버 통신 (POST /products, DELETE /products/:id)hooks/useProductSection.ts: 상품 목록 상태, 추가/삭제 동작hooks/useError.ts: 에러 상태, 도메인 규칙을 호출해 검증 수행 후 boolean 반환util/message.ts: 사용자에게 보여줄 에러 메시지 상수ProductSection.tsx: 입력 상태 관리, 훅 조합, UI 렌더링간단한 예제를 통해 로직을 분리해보는 경험이 재밌었습니다.
우테코에 와서 한 미션중에 거의 처음으로 AI를 아예 안 쓰고 해결한 첫 미션이어서 저에겐 큰 의미가 있었습니다.
"도메인 규칙, 핸들러 메서드 로직, 검증 로직, API 관리 메서드" 를 나누는 과정에서
의존 방향과 각 파일의 책임에 대해 고민해볼 수 있던 유익한 시간이었습니다.
이런 연습용 숙제 너무 좋은것 같아요!
감사합니다 시지프!