Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class FoodServiceImpl implements FoodService {
- private FruitDAO fruitDAO;
- private VegetableDAO vegetableDAO;
- private MeatDAO meatDAO;
- // ... DAO injection stuff
- public List<Meat> getMeat() {
- return meatDAO.getMeat();
- }
- public void addMeat(Meat meat) {
- meatDAO.add(meat);
- }
- public List<Fruit> getFruit() {
- return fruitDAO.getFruit();
- }
- // ... tons of methods that mostly just delegate to DAOs
- }
- // assume foodService is injected at runtime
- public void controllerMethod() {
- foodService.getFruit();
- foodService.getMeat();
- }
- // assume DAOs are injected at runtime
- public void controllerMethod() {
- fruitDAO.getFruit();
- meatDAO.getMeat();
- }
- if (meat.expirationDate-today >= 5 days)
- FridgeDAO.store(meat)
- else if (meat.expirationDate-today <5 days)
- FreezerDAO.store(meat)
- else
- discard(meat)
Add Comment
Please, Sign In to add comment