Re: Assigning responsibility for cancelling an Order
| Newsgroups | gmane.comp.programming.domain-driven-design |
|---|---|
| Message-ID | <[email protected]> |
@Freddy Hansen: I think I can understand what you are saying by populating the CsAgnet class with all functionality. Indeed it would later turn out to be a god object that does everything. @Greg Young: You hit the right spot. We are rebuilding an old system and our domain experts are somewhat accustomed to CRUDy operations. The overall operation is we are cancelling some quantity of an Order. Depending on the quantity cancelled the Order would be flagged as either "partially cancelled" or "fully cancelled". So I guess the reduction causes the cancellation (although the opposite seems totally legit :S) However, I think my main concern is that given the story that we wrote: As a CS Agent, I want to cancel an Order So that we don't ship free Orders My initial thought was this can literally be transalted to agent.cancel(order,cancelledQty); I can even make my users read it and understand what it is doing. Is this a wrong approach? ---In [email protected], <monde.hans@...> wrote : What if the order could cancel and have aspect programming or any other cŕoss cutting concern programming handle loging and auditing. On 21 Aug 2014 6:06 AM, "songoko20000@... mailto:songoko20000@... [domaindrivendesign]" <[email protected] mailto:[email protected]> wrote: 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?