162k views
4 votes
Name two common methods for performing dependency injection.

User Drneel
by
6.2k points

1 Answer

5 votes

Answer:

Constructor Injection

Setter Injection

Method Injection

Step-by-step explanation:

Dependency Injection is to inject all the dependencies required for a class to make it a loosely coupled component from it's dependencies. As the class is loosely coupled from it's dependencies ,changing the logic of dependencies wont effect the class any more.

Constructor Injection: we can inject all the dependencies of the class using constructor

Setter Injection : we will create some properties which will set and return the dependencies of the class

Method Injection: we will create separate method to inject dependencies into the class

User Raducup
by
6.0k points