Skip to content
Ameen Abozaid
Planned lessonMID-060-L07

Demo: redesigning the Order aggregate

  • Lesson 7 of 7
  • Mid-level
On This Lesson 3 topics

This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.

In this lesson

refactor an anemic Order into an aggregate. Prepares MID-060-LAB1.

Draft outline details

Step by step

  1. Start from the setter-based Order and a service with if (status == ...) checks.
  2. Introduce OrderId, Money, and OrderLine value types; remove setters.
  3. Move rules into methods: addLine, place, cancel, with status transitions.
  4. Raise OrderPlaced and OrderCancelled events and publish them from the application service after save.
  5. Planned mistake: hold a full Customer object inside Order. Replace it with CustomerId and explain why loading and locking grew.
  6. Write one unit test per invariant, with no Spring context.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Type to search levels, phases, modules and lessons.