Let's say I have this simple code structure in which I need to create an abstract class and then to define some concrete objects of that type
public abstract class Foo {
protected int var1;
protected String var2;
protected Foo(int var1, String var2) {
this.var1 = var1;
this.var2 = var2;
}
//abstract methods here
}
and
public class ConcreteFoo1 extends Foo{
public ConcreteFoo(int var1, String var2) {
super(var1, var2);
}
//methods override
}
Everytime I add new instance variables, or simply change those already present in the abstract class, I need to change also the concrete classes. Is there a way to avoid this kind of coupling the we do via super()
dependency injection?