I am writing java code and I have a lot of classes which depend on two classes Say D1 and D2
I created the other classes (A1, B1 ...Z1) to have a constructor which will accept instances of D1 and D2 and thus the dependency requirement is satisfied. Later I am wiring them using Spring.
The wiring is happening in a different maven project and I do not want to introduce any coupling to Spring in this maven project so i am not using the @Autowired
annotation.
However my question is that I am not sure if the way I am designing the classes A1 to Z1 is correct ( each of them has the same kind of constructor which is very repetitive)
Is there a design pattern that comes handy in here ?
How would someone design this if there were a lot of classes to depend on say D3 , D4 , and so on ?
Aucun commentaire:
Enregistrer un commentaire