March 10, 2017

#Spring: Dependency Injection

Dependency Injection (DI)
When writing a complex Java application, application classes should be as independent as possible of other Java classes to increase the possibility to reuse these classes and to test them independently of other classes while doing unit testing. Dependency Injection helps in gluing these classes together and same time keeping them independent.

For example, 'DEPENDENCY' means class A is dependent on class B. 'INJECTION' signifies means that class B will get injected into class A by the IoC (Inversion of Control).

Dependency injection can happen in the way of passing parameters to the constructor or by post-construction using setter methods.

No comments:

Post a Comment

RSSChomp Blog Directory