hi, there,
I am reading the HIA and studying its codes now. In the Chapter8, the author tried to "squeeze" all the biz logic into domain model like in the BidForItemCommand
.......
ItemDAO itemDAO = DAOFactory.DEFAULT.getItemDAO();
UserDAO userDAO = DAOFactory.DEFAULT.getUserDAO();
MonetaryAmount newAmount =
new MonetaryAmount(bidAmount, (Currency)Currency.getInstance("usd"));
Bid currentMaxBid = itemDAO.getMaxBid(itemId);
Bid currentMinBid = itemDAO.getMinBid(itemId);
Item item = itemDAO.findById(itemId, true);
newBid = item.placeBid(userDAO.findById(userId, false),
newAmount,
currentMaxBid,
currentMinBid);
.........
Suppose we did not found a item from database and need to create a new one( Of course this will not happen in the CE), my quetsion
is where we should create the new item? In the biz logic , such as in the execute mothod , or within some domain model? In other words, it is whose reponsiblities to create a new object in such situations?
TIA.
OrNot
|