14
Reading the Book "Pro Spring Security" by Carlo Scarioni of Editora Apress, 2013 edition, I came across the following text that left me confused about Ioc:
The basic idea of DI, a type of Inversion of Control (Ioc), is Simply that Instead of having an Object instantiate its needed dependencies, the dependencies are Somehow Given to the Object. In a polymorphic way, the Objects that are Given as dependencies to the target Object that depends on them are known to this target Object just by an abstraction (like an interface in Java) and not by the Exact implementation of the dependency.
Meaning DI is a kind of Inversion of Control (Ioc), but no other project pattern that characterizes as Ioc, while researching found this article (Inversion of Control Containers and the Dependency Injection Pattern - Dependency Injection) of Martin Fowler who explains, but leads to another understanding (which I think is correct):
There are three main Styles of dependency Injection. The Names I’m using for them are Constructor Injection, Setter Injection, and Interface Injection. ...
Well Martin Fowler says there are three styles (Styles), not types, and they’re all Dependency Injection, then what are the other types of Ioc? or would be an error of the edition in question/author of the cited book?
Related: What are the differences between Dependency Injection and Control Inversion?
– rray
In this same Fowler article you referenced it explains an alternative to dependency injection in the implementation of inversion control: the Service Locator. Do not exist "guys" ioc, but yes Patterns design to implement it. In addition to the dependency injection and the Locator service, I have also seen the simple use of configuration files, which determines which service should be used when the code where the control is reversed needs that particular type of service.
– Caffé
Other forms of Ioc implementation I’ve seen: event orientation, Observer, plug-ins or add-ins, Convention over Configuration (where the code where the control was reversed knows which service to instantiate and use based on a default of names for the service), annotations (Java) or Attributes (C#)... I must have seen more but it doesn’t occur to me now.
– Caffé
@Caffé, it would be more appropriate to post your comment as a response.
– Delfino