guys
As i know ,Dependency injection is a implementation of Ioc
But I am not clear about the relationship between dependency lookup & Ioc
,Is dependency lookup also a implementation of Ioc.
Can anyone help this? thanks!
guys
As i know ,Dependency injection is a implementation of Ioc
But I am not clear about the relationship between dependency lookup & Ioc
,Is dependency lookup also a implementation of Ioc.
Can anyone help this? thanks!
I'm no spring expert, but my £0.02.
Dependency injection is externalisation of provision of dependecies.
Dependency lookup is centralisation of provision of dependencies.
with DI the dependencies something has are provided to the object by something else, ideally when the object is constructed. This may or may not involve a framework.
Dependency lookup is when the object itself tries to create the dependencies it needs using some generic service. In spring I believe this is effectively asking Spring for the type of object it needs and the container resolving the object type there and then (ref).
This is effectively the ServiceLocator (anti-) pattern (more details). Although not everyone is convinced its an anti pattern
IMHO you should strive to use DI in all cases and should not use dependency lookup at all.