I am building a wrapper for a library that requires little complex logic. The whole project is 8 builder classes, 4 classes for doing some pre-processing, and a couple visitor classes. Essentially I am just building wrapper classes around a third party library's objects. I was curious whether in a situation like this it is more appropriate to use poor man's di (no framework) or static class dependencies.
For static class dependencies the overhead would be when I have the same static dependency used in multiple classes, you would get some unneeded duplication of instances.
For di, the overhead would be creating the extra builder classes to wire together the objects, in addition to a minor increase is "cognitive load" for those unfamiliar with the concept. For a library this small, without complex business logic, my gut tells me it may be overkill.
Just curious which one you guys would go with, and why. I know the difference in strategies is essentially razor thin.
Dependent Static Classes
public class DoTheThing {
private static final DependencyOne dependencyOne = new DependencyOne();
private static final DependencyTwo dependencyTwo = new DependencyTwo();
public void doSomething(Argument yayImAnArgument){
dependencyOne.do(yayImAnArgument);
dependencyTwo.do(yayImAnArgument);
}
}
vs.
Dependency Injection
public class DoTheThing {
private final DependencyOne;
private final DependencyTwo;
public DoTheThing(DependencyOne dependencyOne, DependencyTwo DependencyTwo){
this.dependencyOne = dependencyOne;
this.dependencyTwo = dependencyTwo;
}
public void doSomething(Argument yayImAnArgument){
dependencyOne.do(yayImAnArgument);
dependencyTwo.do(yayImAnArgument);
}
}