Feb 5th, 2012, 12:14 AM
Dependency Injection : Why we depend on container to inject objects,we can create...
Hi, This is srikanth i am new to spring ,i faced an interview, i have explained the process of ioc and di.how di works they asked me :
" Why container have to inject objects,u can create objects,what is the use of creating objects by container" explain.
and please let me know the exact advantages that can be explained in the interview point of view.
Please, reply for this quotion i have reffered many books but i hope i would find good answer here.
Feb 5th, 2012, 09:59 PM
I would refer to advantages of using DI to answer this question. I would also recommend to you to see a Google I/O presentation by Dhanji. http://code.google.com/p/google-guice/.
I like it because he explains traditionally how we use to create objects, and then how factory pattern eased out the pain and finally about DI. You can also refer to book written by Dhanji himself. I hope this would clear your doubts.