room 도메인과 템플릿 계약 결합 정리#119
Merged
Merged
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.
배경
room모듈의 도메인 타입이template모듈의 public 계약인TemplateCatalog세부 타입을 직접 알고 있었습니다. 구조 테스트는 모듈 외부에서 internal package에 접근하는 문제는 막고 있었지만,room.domain내부로 다른 모듈의 계약 DTO 변환 책임이 들어오는 경우는 별도로 고정하지 못했습니다.이 상태에서는 템플릿 계약의 enum, blueprint 형태가 바뀔 때 방 도메인 모델까지 함께 흔들리고, 실제 방 생성 규칙과 외부 모듈 계약 변환 책임이 한 타입 안에 섞여 읽기 비용이 커집니다.
변경 사항
RoomTemplateSpec.from(TemplateCatalog.TemplateBlueprint)변환 책임을room.application의RoomTemplateSpecFactory로 이동했습니다.RoomMode,DraftOrderStrategy,RoomTemplateSpec에서TemplateCatalog의존을 제거했습니다.RoomInternalPackageIsolationTest에room.domain이template모듈에 직접 의존하지 않는 구조 규칙을 추가했습니다.Room.start가 시작 검증과 상태 전이에 집중하도록StartedGameSnapshotFactory를 도입해 게임 시작 스냅샷 조립을 분리했습니다.RoomFixtureBuilder로 일부 정리해 application 테스트의 생성 잡음을 줄였습니다.RoomTemplateSpecFactoryTest로 옮기고,RoomTemplateSpecTest는 순수 방 생성 명세 invariant를 검증하도록 정리했습니다.AS-IS
room.domain이template.TemplateCatalog의 enum과 blueprint를 직접 참조했습니다.RoomTemplateSpec이 방 생성 명세 invariant와 템플릿 계약 변환을 동시에 맡았습니다.Room.start내부에 시작 가능성 검증, 상태 전이,StartedGameSnapshot상세 조립이 함께 있었습니다.TO-BE
room.application경계에서 끝나고,room.domain은 순수 방 생성 명세만 받습니다.room.domain -> template직접 의존을 회귀로 잡습니다.Roomaggregate는 시작 상태 전이와 invariant에 더 집중하고, 스냅샷 구성은 같은 도메인 패키지의 작은 factory가 맡습니다.검증
./gradlew clean check integrationTest리뷰 포인트
RoomTemplateSpecFactory가 application 경계에 있는 것이 현재 모듈 규칙과 맞는지 확인 부탁드립니다.StartedGameSnapshotFactory는 같은 도메인 패키지의 package-private helper로 두었습니다. aggregate 밖으로 뺀 책임 범위가 적절한지 봐주시면 좋겠습니다.RoomFixtureBuilder는 우선 application 테스트의 반복 조립을 줄이는 범위로만 적용했습니다. 이후 repository/domain 테스트 fixture까지 확대할지는 별도 리팩토링으로 보는 편이 안전합니다.