用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/G1Joshi/Agent-Skills --skill domain-driven-design命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | domain-driven-design |
| description | DDD tactical and strategic patterns. Use for complex domains. |
DDD is a software design approach focusing on modeling software to match a domain according to input from that domain's experts. It is essential for tackling high complexity in the heart of software.
// Aggregate Root
public class Order {
private OrderId id;
private Money totalAmount;
private OrderStatus status;
private List<OrderItem> items; // Aggregates items
// Behaviors (Rich Model), not just Getters/Setters
public void addItem(Product product, int quantity) {
if (this.status != OrderStatus.DRAFT) {
throw new DomainException("Cannot modify confirmed order");
}
this.items.add(new OrderItem(product, quantity));
recalculateTotal();
}
public void confirm() {
if (items.isEmpty()) throw new DomainException("Order empty");
this.status = OrderStatus.CONFIRMED;
// Raise Domain Event
DomainEvents.publish(new OrderConfirmed(this.id));
}
}
A common, rigorous language shared by developers and domain experts. If the expert calls it a "Policy", the code must call it Policy, not UserPlan or Subscription.
The specific boundary within which a particular domain model is defined and applicable. Ideally maps to a Microservice or a Module.
A cluster of associated objects treated as a unit for data changes. External objects can only hold references to the Aggregate Root.
Immutable objects defined by their attributes, not identity (e.g., Money, Address, Email). Two Money(5) objects are equal.
Something that happened in the domain that domain experts care about (OrderShipped, AccountDebited). Used to decouple side effects.
A layer that translates models from an external system (or legacy subsystem) into the model of the current Bounded Context to prevent pollution.
Do:
Don't:
| Error | Cause | Solution |
|---|---|---|
God Class | Aggregate knowing too much. | Split Aggregates; use Domain Events to coordinate. |
Performance | Loading huge Aggregates. | Lazy load is tricky; prefer smaller Aggregates tailored to invariants. |