locked
"Inversion of Control" and "Dependency Inversion Principle" RRS feed

  • Question

  • User1904516115 posted

    Is "Inversion of Control" and "Dependency Inversion Principle" same thing concept?

    Monday, October 7, 2019 5:56 PM

All replies

  • User475983607 posted

    vinodkpasi

    Is "Inversion of Control" and "Dependency Inversion Principle" same thing concept?

    Google the terms and tell us what you think...

    https://en.wikipedia.org/wiki/Inversion_of_control

    Monday, October 7, 2019 6:02 PM
  • User1904516115 posted

    I did not get proper information. Different posts provide contradictory information about same concept.

    Tuesday, October 8, 2019 2:29 AM
  • User1120430333 posted

    An IoC instances the object that is kept in an IoC container so that you don't have to use the 'new' keyword to instance the object gluing your code to the object's implementation, which promotes loose coupling.

    https://ardalis.com/new-is-glue

    https://msdn.microsoft.com/en-us/magazine/mt703433.aspx?f=255&MSPPError=-2147217396

    https://www.tutorialsteacher.com/ioc/inversion-of-control

    DIP is about the abstraction  between high level and low level object.

    https://deviq.com/dependency-inversion-principle/

    Tuesday, October 8, 2019 6:05 AM
  • User577498514 posted

    These are patterns to achieve loose coupling in java programming

    DI(Dependency Injection):
    Dependency injection is a pattern used to create instances of objects that other objects rely upon without knowing at compile time which class will be used to provide that functionality or simply the way of injecting properties to an object is called dependency injection.

    We have three types of Dependency injection

    1. Constructor Injection
    2. Setter/Getter Injection
    3. Interface Injection

    Most Web Dev framework support only Constructor Injection and Setter/Getter Injection.

    IOC(Inversion Of Control):
    Giving control to the container to create and inject instances of objects that your application depend upon, means instead of you are creating an object using the new operator, let the container do that for you. Inversion of control relies on dependency injection because a mechanism is needed in order to activate the components providing the specific functionality

    The two concepts work together in this way to allow for much more flexible, reusable, and encapsulated code to be written. As such, they are important concepts in designing object-oriented solutions.

    Thursday, December 26, 2019 10:25 AM
  • User765422875 posted

    IoC (Inversion of Control) is a generic term meaning rather than having the application call the methods in a framework; the framework calls implementations provided by the application.

    DI (Dependency Injection) is a form of IoC, where implementations get passed into an object through constructors/setters/service-lookups, which the object will depend on to behave correctly.

    More here:

    https://martinfowler.com/articles/injection.html#InversionOfControl

    Friday, December 27, 2019 2:48 PM