انتقل إلى المحتوى
أمين أبوزيد
قيد المراجعةJNR-004-L07

عرض عملي: انعكاس الاعتماديات لمزوّد دفع

  • الدرس 7 من 7
  • 10 دقيقة قراءة
  • Junior
في هذا الدرس 3 موضوعات

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

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

في هذا الدرس

inject a payment provider through an interface. Prepares JNR-004-LAB1.

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

خطوة بخطوة

  1. Show CheckoutService calling new StripeClient() directly; tests need the network.
  2. Extract the PaymentProvider interface.
  3. Inject it through the constructor.
  4. Planned mistake: the interface exposes Stripe-specific types, so the core still depends on Stripe. Fix: use Shop's own types (Money, Receipt) in the interface.
  5. Write a fake provider for tests; run them without a network.
  6. Add a second provider without touching CheckoutService.

اختبر فهمك

Where should the interface live?

أظهر الإجابة

In the core, not in the provider's code.

التطبيق

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

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

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

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