'how to refactor a code with using constructor dependency injection when methods include dependency in dependency method?
i want to refactor a code with using constructor dependency injection to used in unit tests
i not very sure i understand how to refactor code
for example
public class class1{
public int firstMethod()
{
...
...
...
return secondMethod();
}
public int secondMethod()
{
...
...
...
return thirdMethod();
}
public int thirdMethod()
{
...
...
...
return fourthMethod();
}
public int fourthMethod()
{
int a;
...
...
...
return a;
}
if i want to refactor a code that have all this dependeinces(one include one) with constructor dependency injection for unit tests all the 4 methods
i think to do a interface for every method(4 interfaces)
and implements first interface with a constructor that get a impelements class of interface 2
is this a good Idea or i should make something else
thanks.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
