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 agentId
, orderId
and cancelledQty
from the request):
Solution 1:
CSAgent agent= (CSAgent) EmployeeRepository.getById(agentId);
Order order= OrderRepository.getById(orderId);
agent.cancel(order,cancelledQty);
vs
Solution 2:
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 Order
.
So how should I determine the best course of action from a DDD perspective?