Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: Problem Initialising Map Collection

  1. #11
    Join Date
    Apr 2012
    Posts
    15

    Default

    Hi Marten,

    Upon further reading, I realised that you were talking about Automatic DI. I have adapted my program to do as such. Yes, the code looks cleaner, because I no longer have to do getInstance(), it's automatically populated. Out of curiosity, what are the performance sacrifies with Automatic D.I as opposed to do it the convential way using Java? Would you still recommend this approach for an application that has millions of hits per second?

  2. #12
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    Well you are using IoC (Inversion of Control) however you are doing a dependency lookup and not dependency injection.

    There is only a performance hit on startup as your beans are only initialized once (in general services and daos should be singletons). Also which form of DI (annotations, java, xml) you use doesn't really matter and mainly boils down to personal preference. (I still like XML for the general configuration and annotations in the web layer).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #13
    Join Date
    Apr 2012
    Posts
    15

    Default

    Thanks for your information, I appreciate it. However, according to the knowledge that I have IoC & DI work together: IoC is object decoupling concept and DI is the binding mechasim of objects. According to Wiki definition http://en.wikipedia.org/wiki/Inversion_of_control :

    ...Inversion of Control (IoC) is an object-oriented programming practice where the object coupling is bound at run time by an assembler object and is typically not known at compile time ... the binding process is achieved through dependency injection...

  4. #14
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    Dependency Injection is a means to achieve IoC... IoC isn't only achieved through DI there are several different types of IoC which are all mentioned on the wiki page you link to. The key is that the object needing the dependencies doesn't now which (concrete type) dependency it needs (stub, mock, database or whatever implementation).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #15
    Join Date
    Apr 2012
    Posts
    15

    Default

    Thanks Marten!

Tags for this Thread

Posting Permissions

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