This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes OO, Patterns, UML and Refactoring and the fly likes DI Queries Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "DI Queries" Watch "DI Queries" New topic

DI Queries

Soniya Ahuja
Ranch Hand

Joined: Jul 20, 2008
Posts: 83
In my current project we are using a lot of Dependency Injection. I need to know

1. When should setter injection be used and when should we go for constructor injection?
2. Should Programming to Interfaces be used always for DI?
3. How can we program to ask our container to inject dependencies for us (kike in Spring)?

Any help appreciated

Thanks in advance.

SCJP 1.5 | SCWCD 5 | SCJP 6.0
[url][/url] - Online training for Java/JSPs and Servlets/SCJP/SCWCD
Jeanne Boyarsky
internet detective

Joined: May 26, 2003
Posts: 30130

#1 is covered in this thread

#2 - Very few things are "always" true in programming.

#3 - Use Spring?

[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
subject: DI Queries
Similar Threads
Whether or not to use method injection?
DI vs IoC
Is OSGI framework a Dependency Injection killer?
Dependency-Injection Implementation.
DI or BD using EJB 3