Hacker News new | ask | show | jobs
by aembleton 2101 days ago
Annotations make dependency injection simpler. If you have a Controller that has a Service autowired into the constructor then you can test it by passing a mock service into the constructor.

An alternative would be to have a Main method construct all of the objects and pass them into each other, but @Autowired takes care of that for you.

1 comments

I don't see any problem with that, in fact, being explicit is a huge plus. I would take that any day of the week over untraceable code. To be more precise, I'm not just baffled by the popularity of Spring, I don't even comprehend how any of that is a good idea to begin with. It solves a non problem and brings in enormous baggage.