7
← Back to Pattern Arsenal
extra

Dependency Injection

must know

Stage 1: Problem

Problem

You are building an order processing service. When an order is placed, it must:

  1. Charge the customer via a payment gateway
  2. Send a confirmation email
  3. Update inventory in the warehouse system

Each of these depends on an external service. Your OrderService creates these dependencies internally.

How would you structure this so you can test the order logic without hitting real payment APIs, sending real emails, or modifying real inventory?

Write your approach before continuing.


1 / 10 — Problem