Record Events, Don't Send Them
Medium About 35 min Katabench Pro
The Order aggregate emails the customer from inside Ship and Deliver, so the domain depends on an SMTP adapter and the mail leaves before the order is saved. Let the aggregate record domain events and have the application publish them through a port after each save, exactly once, even when the same order is saved again.
The full brief is part of Katabench Pro
Pro opens this kata's brief, its starter code and its grader. To see how the track works first, try Config Is Infrastructure, which is free.
How it is graded
You work across multiple files, and architecture rules turn the design boundaries into executable feedback.
What it practices
- Domain events
- Aggregates record what happened and let the application decide how to react.
Related katas
- Config Is Infrastructure Medium Free The shipping core reads a framework configuration type directly, welding the domain to infrastructure. Invert it behind a core-owned options port, and don't just rename the framework wrapper into the core, which trips a second rule.
- Move the Port Home Medium Free A
*Portabstraction is declared beside its adapter, so the core reaches outward to see its own port. Move the single port into the core; duplicating it leaves a stray copy that fails the role-placement rule. - The Layer Skip Medium Free A controller reaches past the application layer straight into infrastructure for the order total. Route the call back through the middle layer with a port the application owns; a thin pass-through that still touches infrastructure only moves the smell, it doesn't remove it.
- Two Sides of the Hexagon Medium Free A driving (web) adapter reaches the driven (persistence) adapter directly for a quick existence check. Inject the repository "via its interface" and you'll find the seam is still on the wrong side of the hexagon.