Having looked at a bunch of MVC-style web applications, I noticed that it is very important for them to have a very large service interface located in front of the business layer. The implementation of this interface usually includes a DAO group. So you have something like:
public class FoodServiceImpl implements FoodService {
private FruitDAO fruitDAO;
private VegetableDAO vegetableDAO;
private MeatDAO meatDAO;
public List<Meat> getMeat() {
return meatDAO.getMeat();
}
public void addMeat(Meat meat) {
meatDAO.add(meat);
}
public List<Fruit> getFruit() {
return fruitDAO.getFruit();
}
}
Assuming your DAOs are not specific, first of all, why not just expose the DAO to the next level?
So, instead of:
public void controllerMethod() {
foodService.getFruit();
foodService.getMeat();
}
You just
public void controllerMethod() {
fruitDAO.getFruit();
meatDAO.getMeat();
}
On the one hand, it would be nice to have whole guts of the application wrapped in one interface ... on the other hand, you can find a gigantic interface whose implementation does nothing more than delegate the DAO.
, DAO . , , DAO .
" " - , ?