Skip to content

[REFACTOR] User 관심사 불변식을 aggregate 내부로 이동 #397

@Dimo-2562

Description

@Dimo-2562

✨ 리팩토링 할 부분

상위 이슈: #395
선행 이슈: #396, #399

관심사 저장/교체 로직의 핵심 불변식을 InterestCommandService가 아니라
User aggregate가 소유하도록 정리한다.


🏷️ 도메인

  • 👤 domain:user

📌 현재 코드의 문제점

  • 관심 카테고리/키워드 조립과 유효성 검증이 InterestCommandService에 몰려 있다.
  • "키워드는 선택된 카테고리에 속해야 한다" 규칙이 aggregate 내부가 아니라 서비스 레이어에 있다.
  • user.getInterestCategories().clear() 같은 컬렉션 직접 조작이 서비스에 노출돼 있다.

🎯 리팩토링 방향

  • User.replaceInterests(...) 또는 동등한 aggregate 메서드를 도입한다.
  • 관심사 교체 시 카테고리/키워드 조립과 검증을 aggregate 내부에서 처리한다.
  • InterestCommandService는 request 해석과 트리거 orchestration 중심으로 축소한다.

✅ 작업 체크리스트

  • aggregate 내부 관심사 교체 메서드 도입
  • invalid keyword-category 조합 검증 책임 이동
  • 서비스 직접 컬렉션 조작 제거
  • 관련 테스트를 aggregate 중심 의도로 재정렬

💡 기대 효과

  • 가독성 향상
  • 유지보수성 향상
  • 기타: 관심사 불변식 책임을 aggregate 내부로 수렴

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions