mercredi 6 juillet 2016

Using methods of one DAO into another

I have 3 Service classes in my application each written for specific functionalities with respective DAO interfaces & their implementation classes. All services have different packages.

Say I have

AService.java & ADAO.java ADAO interface is injected into AService.java class. Similarly I have

BService.java & BDAO.java

CService.java & CDAO.java

Now I want to refer some methods of BDAO & CDAO implementation classes in AService.java

What should be the best way to do that?

  1. I inject BDAO & CDAO in AService.java. Would that be a good practice? Services are tightly coupled in this scenario.

  2. I write the redundant code in respective DAOs.

  3. I create a generic DAO & try to extract all the common methods from all the individual DAOs & put into that. This is an extensive task. Also I am not sure in future which method of which DAO will be required in which particular service.

Aucun commentaire:

Enregistrer un commentaire