Tuesday, May 7, 2024

IoC - DI


Inversion of Control (IoC) design is achieved using service locator, factory pattern or Dependency Injection (DI).  DI is the recent framework to build in the modern application framework.

As depicted in the diagram, DI has 4 core elements

  1. Client - dependent role
  2. Server - functionality provider 
  3. Injector - creates server instances to client
  4. Interface - communication contract between client and server

DI decouples objects from their dependencies by receiving from an external source - not with direct implementations.

Multiple ways of dependency injection implementations are available in github https://github.com/gsenthilvel/InversionOfControl 

Top-3 advantages

  1. Loosely coupled
  2. Unit testability
  3. Scalability

Top-3 disadvantages

  1. Complexity to develop
  2. Reduced transparency
  3. Overhead to troubleshoot/debug


No comments:

Post a Comment