Skip to content

refactor: 値オブジェクトを所属する集約ディレクトリに移動#80

Merged
KinjiKawaguchi merged 2 commits intodevelopfrom
refactor/move-value-objects-into-aggregates
Mar 12, 2026
Merged

refactor: 値オブジェクトを所属する集約ディレクトリに移動#80
KinjiKawaguchi merged 2 commits intodevelopfrom
refactor/move-value-objects-into-aggregates

Conversation

@KinjiKawaguchi
Copy link
Copy Markdown
Member

@KinjiKawaguchi KinjiKawaguchi commented Mar 11, 2026

Summary

  • domain/value-objects/ を廃止し、各値オブジェクトを使用元の集約ディレクトリに移動
    • Email, UniversityEmail, Departmentsaggregates/member/
    • LightningTalkDuration, Urlaggregates/event/
  • ValueObject 基底クラスを domain/base/ に移動
  • 型別ではなくドメイン概念別のディレクトリ構成に統一

Motivation

既存の構造では値オブジェクトがビルディングブロックの型別(value-objects/)にトップレベルで切り出されており、どの集約に属する概念なのかが不明瞭だった。

各値オブジェクトは実際には特定の集約でのみ使用されているため、使用元の集約ディレクトリに配置することで、ドメイン概念の凝集度を高める。

🤖 Generated with Claude Code

value-objects/ を廃止し、各値オブジェクトを使用元の集約内に配置。
ValueObject基底クラスはdomain/base/に移動。
型別ではなくドメイン別のディレクトリ構成に統一する。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 11, 2026 10:58
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

Open in Devin Review

Comment on lines +5 to +6
export * from "./LightningTalkDuration";
export * from "./Url";
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚩 Url and LightningTalkDuration are now scoped to the event aggregate

By moving Url into domain/aggregates/event/Url.ts and LightningTalkDuration into domain/aggregates/event/LightningTalkDuration.ts, these value objects are now conceptually part of the event aggregate. Currently no other aggregate uses Url or LightningTalkDuration, so this is fine. However, if a future aggregate (e.g., member) needs a Url value object, importing it from the event aggregate would create a cross-aggregate dependency, which is a DDD anti-pattern. The previous shared value-objects location avoided this. This is a design trade-off worth being aware of — if Url is a general-purpose value object, it might belong in domain/base/ alongside ValueObject.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

DDDのドメイン別ディレクトリ構成へ寄せるため、値オブジェクトを domain/value-objects/ から各集約配下へ移動し、共通基底 ValueObjectdomain/base/ に再配置するPRです。

Changes:

  • domain/value-objects/ を廃止し、VOを aggregates/member / aggregates/event へ移動
  • ValueObjectdomain/base/ に移動し、domain/index.ts から base を再export
  • 参照側のimport/export(barrel)を移動先に合わせて更新

Reviewed changes

Copilot reviewed 13 out of 15 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/domain/value-objects/index.ts value-objects のbarrel exportを削除(ディレクトリ廃止に伴う)
src/domain/index.ts base をexportし、従来の value-objects export を削除
src/domain/base/index.ts ValueObject のbarrel exportを追加
src/domain/base/ValueObject.ts ValueObject 基底クラスを新配置
src/domain/aggregates/member/index.ts member集約でVO(Departments/Email/UniversityEmail)をexport
src/domain/aggregates/member/UniversityEmail.ts UniversityEmail VOをmember集約配下へ追加
src/domain/aggregates/member/Member.ts VO参照を #domain/value-objects から同集約配下へ変更
src/domain/aggregates/member/Email.ts ValueObject のimport先を domain/base 配下へ変更
src/domain/aggregates/member/Departments.ts ValueObject のimport先を domain/base 配下へ変更
src/domain/aggregates/event/index.ts event集約でVO(LightningTalkDuration/Url)をexport
src/domain/aggregates/event/Url.ts ValueObject のimport先を domain/base 配下へ変更
src/domain/aggregates/event/LightningTalkDuration.ts ValueObject のimport先を domain/base 配下へ変更
src/domain/aggregates/event/LightningTalk.ts VO参照を #domain/value-objects から同集約配下へ変更
src/domain/aggregates/event/Exhibit.ts VO参照を #domain/value-objects から同集約配下へ変更
src/domain/aggregates/event/Event.ts VO参照を #domain/value-objects から同集約配下へ変更

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@KinjiKawaguchi KinjiKawaguchi merged commit 168cf27 into develop Mar 12, 2026
3 checks passed
@KinjiKawaguchi KinjiKawaguchi deleted the refactor/move-value-objects-into-aggregates branch March 12, 2026 03:32
KinjiKawaguchi added a commit that referenced this pull request Mar 23, 2026
## Summary

- `domain/value-objects/` を廃止し、各値オブジェクトを使用元の集約ディレクトリに移動
  - `Email`, `UniversityEmail`, `Departments` → `aggregates/member/`
  - `LightningTalkDuration`, `Url` → `aggregates/event/`
- `ValueObject` 基底クラスを `domain/base/` に移動
- 型別ではなくドメイン概念別のディレクトリ構成に統一

## Motivation


既存の構造では値オブジェクトがビルディングブロックの型別(`value-objects/`)にトップレベルで切り出されており、どの集約に属する概念なのかが不明瞭だった。

各値オブジェクトは実際には特定の集約でのみ使用されているため、使用元の集約ディレクトリに配置することで、ドメイン概念の凝集度を高める。

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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.

2 participants