Dependency injection and IoC

Inversion of Control (IoC) is a programming technique in which object coupling is bound at runtime by an assembler object and is typically not known at compile time using static analysis. IoC can be achieved using dependency injection. We can say that IoC is the idea and dependency injection is its implementation. Now, what is dependency injection? Let's find out.

Dependency injection is a technique where one component supplies dependencies for another component during the instantiation time. The definition sounds confusing, right? Let's explain it with an example. Consider the following interfaces:

    interface Employee { 
      fun executeTask() 
    } 
    interface Task { 
      fun execute() 
    } 

A common implementation of the preceding ...

Get Reactive Programming in Kotlin now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.