24.12.2014 Views

Rich Domain Model.pdf

Rich Domain Model.pdf

Rich Domain Model.pdf

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Transaction Script의 단점<br />

기졲 코드 수정<br />

@Override<br />

public Reservation reserveShowing(int customerId, int showingId, int audienceCount) {<br />

Showing showing = showingDAO.selectShowing(showingId);<br />

Movie movie = movieDAO.selectMovie(showing.getMovieId());<br />

Rule rule = findRule(showing, movie);<br />

}<br />

Money fee = movie.getFee();<br />

if (rule != null) {<br />

fee = calculateFee(movie);<br />

}<br />

private Money calculateFee(Movie movie) {<br />

Discount discount = discountDAO.selectDiscount(movie.getId());<br />

Reservation result = makeReservation(customerId, showingId, audienceCount, fee);<br />

reservationDAO.insert(result);<br />

if (discount.isAmountType()) {<br />

return movie.getFee().minus(Money.wons(discount.getFee()));<br />

} else if (discount.isPercentType()) {<br />

return result;<br />

return movie.getFee().minus(<br />

movie.getFee().times(discount.getPercent()));<br />

} else if (discount.isMilleageType()) {<br />

return movie.getFee().minus(<br />

movie.getMileageBaseAmount().times(discount.getMileageFactor()));<br />

}<br />

}<br />

return movie.getFee();<br />

42 / 문서의 제목

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!