Why would you inject a dependency rather than construct it inside the class that uses it?

Answer it out loud before you open anything. The value of the flags below is in comparing them to what you actually said — including whether you named a cost, or only a principle.

The situation behind the question

A service class constructs its own database client, HTTP client, clock and logger in its constructor. It has one test, which starts a real database in a container and takes ninety seconds. A new engineer has proposed adding a dependency injection container to the project.

React to this

Say what you would change, what you would leave alone, and what you would need to know first.

The code, or the design, as it stands
The constructor is:

```ts
class SubscriptionService {
  private db = new PostgresClient(process.env.DATABASE_URL!)
  private http = new HttpClient({ timeout: 5000 })
  private logger = Logger.getInstance()
  renew(id: string) {
    const sub = this.db.load(id)
    if (sub.expiresAt < new Date()) { /* ... */ }
    if (Math.random() < 0.1) this.http.post('/sample', sub)
  }
}
```

Which of these five dependencies would you extract first, and what test becomes possible immediately after?

What it is really testing

Whether the candidate can separate three ideas that get conflated: injection (who supplies a dependency), inversion (which module owns the contract), and the container (a tool for wiring). Most candidates answer "for testing" and stop; the interesting part is what injection buys when nobody is testing.

Where the mechanism is taught