ddd-tactical-patterns
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDDD Tactical Patterns
DDD战术模式
Use this skill when
适用场景
- Translating domain rules into code structures.
- Designing aggregate boundaries and invariants.
- Refactoring an anemic model into behavior-rich domain objects.
- Defining repository contracts and domain event boundaries.
- 将领域规则转化为代码结构。
- 设计聚合边界与不变量。
- 将贫血模型重构为富行为领域对象。
- 定义仓储契约与领域事件边界。
Do not use this skill when
不适用场景
- You are still defining strategic boundaries.
- The task is only API documentation or UI layout.
- Full DDD complexity is not justified.
- 仍在定义战略边界时。
- 仅需处理API文档或UI布局时。
- 无需引入完整DDD复杂度时。
Instructions
操作指南
- Identify invariants first and design aggregates around them.
- Model immutable value objects for validated concepts.
- Keep domain behavior in domain objects, not controllers.
- Emit domain events for meaningful state transitions.
- Keep repositories at aggregate root boundaries.
If detailed checklists are needed, open .
references/tactical-checklist.md- 首先识别不变量,围绕其设计聚合。
- 为已验证的概念建模不可变值对象。
- 将领域行为保留在领域对象中,而非控制器。
- 在发生有意义的状态转换时发布领域事件。
- 将仓储限定在聚合根边界。
如需详细检查清单,请打开。
references/tactical-checklist.mdExample
示例
typescript
class Order {
private status: "draft" | "submitted" = "draft";
submit(itemsCount: number): void {
if (itemsCount === 0) throw new Error("Order cannot be submitted empty");
if (this.status !== "draft") throw new Error("Order already submitted");
this.status = "submitted";
}
}typescript
class Order {
private status: "draft" | "submitted" = "draft";
submit(itemsCount: number): void {
if (itemsCount === 0) throw new Error("Order cannot be submitted empty");
if (this.status !== "draft") throw new Error("Order already submitted");
this.status = "submitted";
}
}Limitations
局限性
- This skill does not define deployment architecture.
- It does not choose databases or transport protocols.
- It should be paired with testing patterns for invariant coverage.
- 本技能不涉及部署架构定义。
- 不负责选择数据库或传输协议。
- 需搭配测试模式以覆盖不变量验证。