①
Constructor
4
②
Setter
1½
③
Field
0
OrderService receives a MessageSender via its constructor
OrderService
needs a MessageSender
constructor injection
Scorecard
4 green checks
Required dependency
guaranteed
at construction?
✓
Yes
Can be
final
/ immutable?
✓
Yes
Testable with a plain
new + fake
, no framework?
✓
Yes
Dependency
visible
in the public API?
✓
Yes
—
—
▸
Same
OrderService
, three ways to hand it a
MessageSender
. Switch tabs and watch the scorecard —
constructor
is the only style that wins every row.