I understand that objects external to an aggregate shouldn't hold references to entities and value objects belonging to the aggregate. My question if this also applies to the Application Service that exposes the use cases to the client code.
For example, if I have an Order aggregate, and Order Line is a value object inside the aggregate, what would be a more recommended approach:
Option 1: referencing child objects from Application Service
class OrderApplicationService
# code ommited
def removeOrderLine(order_id, order_line_product_id)
order = OrdersRepository.find(order_id)
order_line = order.find_line_by_product(order_line_product_id)
order.remove_line(order_line)
OrdersRepository.save(order)
end
Option 2: using primitive values instead of child objects
class OrderApplicationService
# code ommited
def removeOrderLine(order_id, order_line_product_id)
order = OrdersRepository.find(order_id)
order.remove_line_by_product(order_line_product_id)
OrdersRepository.save(order)
end
end