rrezartprebreza/spring-boot-skills / skills/spring-boot-4/domain-driven-design
domain-driven-design
VerifiedUse when evolving aggregate invariants, value objects or domain events in an existing DDD-style Spring Boot 4 application, or when DDD is explicitly requested. Preserve existing API identifiers and architecture when changing domain behavior.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 8.4 KB |
| agents/openai.yaml | config | 205 B |
| examples/bad-aggregate.java | other | 1.5 KB |
| examples/good-aggregate.java | other | 3.2 KB |
| templates/DomainEvent.java | other | 1.3 KB |
| templates/Money.java | other | 2.6 KB |
examples/bad-aggregate.java
View on GitHub// BAD — anemic model, no invariant enforcement, no typed IDs, no events
@Entity
@Data // generates public setters — anyone can mutate state
@NoArgsConstructor // public no-arg constructor allows invalid objects
public class Order {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; // Long ID — not a typed value object
private Long customerId; // Long — should be CustomerId value object
private String customerEmail; // raw String — should be EmailAddress value object
@Enumerated(EnumType.ORDINAL) // ORDINAL breaks if enum is reordered
private OrderStatus status;
private BigDecimal total; // raw BigDecimal — should be Money value object
@OneToMany(mappedBy = "order") // missing cascade, orphanRemoval
private List<OrderItem> items; // not initialized — NPE risk
// No behavior methods — all logic will live in service:
// - No addItem() method
// - No place() method
// - No state transition validation
// - No domain events
// - Total is set manually from outside, not calculated
// External code does:
// order.getItems().add(new OrderItem(...)); // bypasses aggregate boundary
// order.setStatus(OrderStatus.PLACED); // no invariant check
// order.setTotal(calculateTotal(items)); // logic outside domain
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |