Skip to content

room 도메인과 템플릿 계약 결합 정리#119

Merged
NaMinhyeok merged 1 commit into
mainfrom
codex/room-boundary-refactor
May 2, 2026
Merged

room 도메인과 템플릿 계약 결합 정리#119
NaMinhyeok merged 1 commit into
mainfrom
codex/room-boundary-refactor

Conversation

@NaMinhyeok
Copy link
Copy Markdown
Contributor

배경

room 모듈의 도메인 타입이 template 모듈의 public 계약인 TemplateCatalog 세부 타입을 직접 알고 있었습니다. 구조 테스트는 모듈 외부에서 internal package에 접근하는 문제는 막고 있었지만, room.domain 내부로 다른 모듈의 계약 DTO 변환 책임이 들어오는 경우는 별도로 고정하지 못했습니다.

이 상태에서는 템플릿 계약의 enum, blueprint 형태가 바뀔 때 방 도메인 모델까지 함께 흔들리고, 실제 방 생성 규칙과 외부 모듈 계약 변환 책임이 한 타입 안에 섞여 읽기 비용이 커집니다.

변경 사항

  • RoomTemplateSpec.from(TemplateCatalog.TemplateBlueprint) 변환 책임을 room.applicationRoomTemplateSpecFactory로 이동했습니다.
  • RoomMode, DraftOrderStrategy, RoomTemplateSpec에서 TemplateCatalog 의존을 제거했습니다.
  • RoomInternalPackageIsolationTestroom.domaintemplate 모듈에 직접 의존하지 않는 구조 규칙을 추가했습니다.
  • Room.start가 시작 검증과 상태 전이에 집중하도록 StartedGameSnapshotFactory를 도입해 게임 시작 스냅샷 조립을 분리했습니다.
  • 반복되던 테스트용 room/game 조립을 RoomFixtureBuilder로 일부 정리해 application 테스트의 생성 잡음을 줄였습니다.
  • 템플릿 계약 변환 테스트는 RoomTemplateSpecFactoryTest로 옮기고, RoomTemplateSpecTest는 순수 방 생성 명세 invariant를 검증하도록 정리했습니다.

AS-IS

  • room.domaintemplate.TemplateCatalog의 enum과 blueprint를 직접 참조했습니다.
  • RoomTemplateSpec이 방 생성 명세 invariant와 템플릿 계약 변환을 동시에 맡았습니다.
  • Room.start 내부에 시작 가능성 검증, 상태 전이, StartedGameSnapshot 상세 조립이 함께 있었습니다.
  • 일부 application 테스트가 방과 게임 시작 상태를 직접 길게 조립해 리팩토링에 취약했습니다.

TO-BE

  • 템플릿 계약 해석은 room.application 경계에서 끝나고, room.domain은 순수 방 생성 명세만 받습니다.
  • 구조 테스트가 room.domain -> template 직접 의존을 회귀로 잡습니다.
  • Room aggregate는 시작 상태 전이와 invariant에 더 집중하고, 스냅샷 구성은 같은 도메인 패키지의 작은 factory가 맡습니다.
  • application 테스트는 공용 fixture builder를 통해 핵심 시나리오만 드러내도록 정리했습니다.

검증

  • ./gradlew clean check integrationTest

리뷰 포인트

  • RoomTemplateSpecFactory가 application 경계에 있는 것이 현재 모듈 규칙과 맞는지 확인 부탁드립니다.
  • StartedGameSnapshotFactory는 같은 도메인 패키지의 package-private helper로 두었습니다. aggregate 밖으로 뺀 책임 범위가 적절한지 봐주시면 좋겠습니다.
  • RoomFixtureBuilder는 우선 application 테스트의 반복 조립을 줄이는 범위로만 적용했습니다. 이후 repository/domain 테스트 fixture까지 확대할지는 별도 리팩토링으로 보는 편이 안전합니다.

@NaMinhyeok NaMinhyeok marked this pull request as ready for review May 2, 2026 14:55
@NaMinhyeok NaMinhyeok merged commit 7c60356 into main May 2, 2026
1 check passed
@NaMinhyeok NaMinhyeok deleted the codex/room-boundary-refactor branch May 2, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant