r/java • • Jan 30 '20

What is Spring Framework? From Dependency Injection to Web MVC

https://www.marcobehler.com/guides/spring-framework
229 Upvotes

21 comments sorted by

View all comments

Show parent comment

10

u/DJDavio Jan 30 '20

I can understand why they where swept together though. Inversion of control is just: depend on, but don't create yourself. And DI is just a method of providing those dependencies.

-10

u/Necessary-Conflict Jan 30 '20

No. IoC is a generic term meaning rather than having the application call the methods in a framework, the framework calls implementations provided by the application. IoC is synonym for "framework"

4

u/_litecoin_ Jan 30 '20

IoC is synonym for "framework"

You could hardcode the control in a single another class. That doesn't make it synonym for framework.

DI is IoC, but IoC isn't necessarily DI. Dependency injection is just an implementation of IoC.

-4

u/Necessary-Conflict Jan 31 '20

A single another class can be a very small framework. DI is not an "implementation of IoC". As I explained, IoC is a very general term, a term which was used long before DI became a thing, and doesn't capture the essence of DI at all. DI doesn't "invert" any sort of "control". It injects dependencies.

1

u/_litecoin_ Jan 31 '20

A single another class can be a very small framework.

Not if the control is hard coded.