This question arised from my work on a Grails application, but it applies to pretty much every web application developed in layers. Here's a simple example:
class OrderService {
// Option 1
def shipOrder(Order order) {
order.status = OrderStatus.SHIPPED
emailService.sendShipmentEmail(order)
// ...
}
// Option 2
def shipOrder(long orderId) {
def order = Order.get(orderId)
order.status = OrderStatus.SHIPPED
emailService.sendShipmentEmail(order)
// ...
}
}
Is any of these options documented as being better than the other one?