انتقل إلى المحتوى
أمين أبوزيد
درس مخطط لهMID-059-L06

عرض عملي: تحويل Shop إلى منافذ ومحوّلات (ports and adapters)

  • الدرس 6 من 6
  • Mid-level
في هذا الدرس 3 موضوعات

هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.

نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.

في هذا الدرس

refactor Shop live. Prepares MID-059-LAB1.

تفاصيل المخطط المبدئي

خطوة بخطوة

  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.

التطبيق

طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.

المختبر والتمارين الاختبار

تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.

اكتب للبحث في المستويات والمراحل والوحدات والدروس.