Announcement Announcement Module
Collapse
No announcement yet.
How far to go with IOC ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How far to go with IOC ?

    I will shortly be putting together a small course on Spring for the developers in my company, and one of the things I was wondering about was how far do you go when injecting in beans.

    If I just have some code like this:

    Thing thang = new Thing();

    should I always make thang a Spring bean ?

    Is there a rule of thumb to say when I should and when I shouldn't ?

    I want to head off at the pass the "What's the point of doing it for every new creation of an object ?" question.

  • #2
    the IoC container adds a lot of value when you have injections of objects that might be reused or require some configuration themselves. However, that doesn't mean you don't need to create objects anymore and declare everything inside an xml.
    If I have a configuration to do then I use the xml - for simple, nested objects like Integer that are used only inside a method I simply create and use them.

    P.S. since you mention training I can't help to point out the training page. Besides a "from the source" training, once gets a lot of inside of approaches and advices about application development in general, not just particular to spring.

    Comment

    Working...
    X