Skip to content
Ameen Abozaid
Planned lessonMID-059-L06

Demo: turning Shop into ports and adapters

  • Lesson 6 of 6
  • 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 Shop live. Prepares MID-059-LAB1.

Draft outline details

Step by step

  1. Start from the layered Shop: OrderService imports JpaOrderRepository and a Stripe client.
  2. Create the orders domain package; move Order as a plain class without JPA annotations.
  3. Define outbound ports OrderRepository and PaymentGateway in the domain; add the inbound port PlaceOrderUseCase.
  4. Write adapters: a JPA adapter with a separate OrderEntity and mapper, and a payment adapter.
  5. Planned mistake: put @Entity back on the domain Order "to save a mapper". Add an ArchUnit test that fails on jakarta.persistence imports in the domain; remove the annotation and keep the mapper.
  6. Swap in a fake payment adapter; the domain tests still pass untouched.

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.