Questions about IoC and DI for the Authors of 'Professional Java EE Design Patterns'
posted 2 years ago
Hi Murat & Alex,
First i want to congratulate you for your book and wish you a good luck.
My question is regarding the the Inversion of Control (IoC) and Dependency Injection (DI) patterns, could you please explain the difference between them? when learning about Spring i saw that people keep talking about Ioc and Dependecy Injection like if its the same thing! which make me confused if there is any difference betwen them, or if one include the other.
To cut it short, J2EE heavily depended on JNDI lookups which was definitely cumbersome. Very soon dependency injection became a popular idiom to solve this situation. As far as I know DI was the first term to describe this approach. However, Martin Fowler heavily advocated the term inversion of control to describe this approach. Today IoC is more like a generic term for both DI and also IoC containers where DI is more used for describing the injection of resources either via fields or methods.
Most of the time people use both terms to refer the exact same meaning.