Card 05/ 05
All 5 cards
RecapDifficulty: Beginner1 min
What This Topic Established
A hard-coded new inside a class ties that class to one concrete implementation, and every test and every future swap pays for it.
Inversion of Control is the principle — something other than the class decides what it depends on. Dependency Injection is the technique — handing the dependency in, usually through the constructor. Both examples did this by hand, with no framework.
The thing that will do this handing-in automatically, for every bean in a real application, is called the container — the next topic.