• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
  • paul wheaton
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Rob Spoor
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:

IOC Vs DI Vs Factory Pattern

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am new to Spring concepts. As I read IOC, I am confused what wrong with Factory Pattern that we are going for this IOC Pattern(hope this is also a pattern).

Please provide some basic examples for IOC/DI/Factory Pattern with their differences.

Thanks & Regards,
Ravi.
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Inversion of Control (IoC) and Dependency Injection (DI) usually refer to the same thing. IoC is a more general concept (instead of doing X itself, a class relies on some other class to do it) DI is IoC as applied to dependent classes (instead of creating a class that I depend on, it will be passed to me). DI is the most common use of IoC, so usually when they are discussed the terms are used interchangeably.

The Factory Pattern's main concern is creating things - DI's main concern is how things are connected together.

In practice, these two concerns (creating and connecting) are usually related, so most DI/IoC containers do both. You could think of most implementations as very configurable factories - but because the implementations address both concerns - not because the Factory pattern and DI/IoC are the same.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And it isn't an OR thing. I can have Factories and still use IOC/DI

Mark
 
I like you because you always keep good, crunchy cereal in your pantry. This tiny ad agrees:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic