Skip to main content


Showing posts from February 12, 2018

IoC, DI and Spring

Greetings! "program to interface not implementation" IoC and DI Both words are used interchangeably in Java world but there is a difference. Inversion of Control is a more general concept Dependency Injection is a concrete pattern IoC - Inversion of Control Inverts responsibility of managing object life cycle (create, initialize, destroy, etc). In simple term, let someone else to create objects for you instead of using "new" in code itself. Normally this someone else is Ioc Container. IoC Container Framework to create dependencies and inject them automatically when required. DI - Dependency Injection Objects are depending on other Objects. In DI, Objects are given (injects) their dependencies (other objects) through their constructors, methods, fields. IoC with DI So if DI means objects are injected who is doing that. Here is where IoC comes in to play. With IoC dependencies are managed by the container. Spring Framework Spring Framework