Re: Assigning responsibility for cancelling an Order

"Freddy Hansen [email protected] [domaindrivendesign]" <[email protected]>
Newsgroups gmane.comp.programming.domain-driven-design
Message-ID <CADqkBqhEONO=ShFYajkLLFVXOUsvTcXG3ZKrwwp17R_koMaLEg@mail.gmail.com>
Hi! Don't be afraid that you are not following DDD if you don't execute
code in the exact same order as the domain experts are saying them. It may
lead you into a very bad place.

 In this case it seems like the person also might just as well have said
"an order can be cancelled" followed by "we also need to log who cancelled".

Also consider what would happen if you put all behavior on the agent object
because an agent can do "everything"? What if you have more "roles" that
use he same functionality?

IMO Go with the cancel method on the order, passing in a value
object/snapshot representing the agent/user.

Btw: it may be that you have two different concepts - canceling and
reduction?

Freddy Hansen

Den tirsdag 19. august 2014 skrev [email protected]
[domaindrivendesign] <[email protected]> følgende:

>
>
> 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?
>
>  
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.