Card 05/ 05
Recap: Why Spring Exists
The cost of a hard-coded new, the principle and the technique, and the shape they share.
Why Spring exists comes down to the four ideas below, each listed with the card that covers it.
| The idea | Where |
|---|---|
A hard-coded new ties a class to one implementation, and every test and swap pays for it | Hard-Coded Dependencies and Inversion of Control |
| Inversion of Control is the principle; Dependency Injection is the technique that carries it out | Hard-Coded Dependencies and Inversion of Control |
| A constructor parameter is the whole technique, and needs no framework | Dependency Injection Example: A Repository Passed to the Constructor |
| The same shape works for any dependency: depend on an interface, let the caller choose | Dependency Injection Example: A Mail Client Instead of a Database |
Spring's container is what does this handing-in automatically, for every bean in an application, and it is what the rest of Spring Core is about.
← → move through sections and cards