Thursday, 20 April 2017

spring - Dependency injection design pattern






Possible Duplicate:
What is dependency injection?






Spring uses dependency injection pattern. Can someone show a simple example of this pattern?

I heard there is another pattern called service locator, which one is better?


Answer



Service locator is a J2EE "Core Patterns" idiom.



Let's define "better" before we debate it, shall we?



They aren't really competitors, IMO. Not every dependency happens over a network. Spring can do remoting and proxying, but that's not the sum of all dependencies.


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...