Performance: IoC container mental model
MEDIUM IMPACT
This concept affects application startup time and memory usage by managing object creation and dependencies.
@Service public class Service { private final Repository repo; public Service(Repository repo) { this.repo = repo; } } // Repository is managed by Spring IoC container and injected automatically
public class Service { private Repository repo = new Repository(); // direct instantiation inside the class }
| Pattern | Object Creation | Dependency Management | Startup Impact | Verdict |
|---|---|---|---|---|
| Direct instantiation in classes | Multiple instances per use | Manual, tight coupling | Higher startup time and memory | [X] Bad |
| IoC container with singleton beans | Single shared instance | Automatic, loose coupling | Lower startup time and memory | [OK] Good |