Results 1 to 2 of 2

Thread: How far to go with IOC ?

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Posts
    602

    Default 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. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    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.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •