During a conversation with our Domain Expert we can across this feature:
A Customer service agent can cancel an Order by decreasing its quantity. To cancel an Order we decrease its quantity by the specified quantity, change its status to either partially cancelled or fully cancelled and log the CS agent who issued the cancellation.
We are currently split between several solutions (assuming we have the
cancelledQty from the request):
CSAgent agent= (CSAgent) EmployeeRepository.getById(agentId); Order order= OrderRepository.getById(orderId); agent.cancel(order,cancelledQty);
CSAgent agent= (CSAgent) EmployeeRepository.getById(agentId); Order order= OrderRepository.getById(orderId); order.cancel(cancelledQty,agent);
Solution 1 really captures what the requirements is conveying and reads really well; however, solution 2 seems more natural when coding the implementation of the cancel() method as I'll mostly update fields in the
Order class itself which I hope to keep
private with no public setters.
The only thing I need from the
CSAgnet class is a snapshot of its data to be stored with the
So how should I determine the best course of action from a DDD perspective?