Sunday, December 11, 2016

DIP vs DI vs IoC vs SL

Whenever DIP is discussed, a lot of developers confuse this with DI and IoC. So today we are going to see how these three are different from one another.
  • DIP - Dependency Inversion Principe
    • Its a principle which says 
      • High level modules should not depend on low level modules. Both should dependent upon abstraction.
      • Abstraction should not depend upon details. Details should depend on abstraction.
    • It never say how this principle can be achieved.
  • IoC - Inversion of Control
    • A programming style where a framework or run-time controls the flow.
  • DI - Dependency Injection
    • A software Design Pattern of injecting a class's dependencies into at run-time.
    • DI uses a builder object to initialize objects and provide the required dependencies to the object. 
    • There are three ways to achieve this
      • Constructor Injection
      • Setter Injection (Property Injection)
      • Interface Injection
  • SL - Service Locator
    • Introduces a locator object that, objects use to resolve dependencies.

No comments:

Post a Comment