dimanche 25 janvier 2015

Which design pattern to apply


class A { doSomethingForA(); }

class B { doSomethingForB(); }

class LetsSaySomeResource {

@Inject
private A classAInstance;
@Inject
private B classBInstance;

public void getDataBasedOnA(){
classAInstance.doSomethingForA();
}
public void getDataBasedOnB(){
classBInstance.doSomethingForB();
}
}


Now the requirement is we want to fetch some data based on A and B both and later on maybe more classes like A and B will be added to get data based on this. How shall i make the design more flexible?


Like,



public void getDataBasedOnAandB(){
}


Or, later on C class can come, so i dont want to keep injecting filters like A,B.... Can someone help on this?


Aucun commentaire:

Enregistrer un commentaire