Performance: Constructor injection (preferred)
MEDIUM IMPACT
This affects application startup time and memory usage by managing dependency creation efficiently.
public class Service {
private final Repository repo;
public Service(Repository repo) {
this.repo = repo;
}
}public class Service {
@Autowired
private Repository repo;
public Service() {}
}| Pattern | Reflection Usage | Startup Delay | Memory Overhead | Verdict |
|---|---|---|---|---|
| Field Injection (@Autowired on fields) | High | Medium | Higher due to proxies | [X] Bad |
| Constructor Injection (preferred) | Low | Low | Lower | [OK] Good |