I read Evans, Nilson and McCarthy, among others, and understood the concepts and arguments for domain-driven design; however, it is difficult for me to combine all this in a real application. The lack of complete examples made me scratch my head. I found a lot of frameworks and simple examples, but so far nothing shows how to create a real business application after DDD.
Using a typical order management system, consider the case of canceling an order. In my design, I see an OrderCancellationService with the CancelOrder method, which takes order # and reason as parameters. Then he must follow these “steps”:
- Make sure that the current user has the necessary permission to cancel the order
- Get Order object with specified order # from OrderRepository
- Make sure the order can be canceled (if the service asks for the order status to evaluate the rules or if the Order has a CanCancel property that encapsulates the rules?)
- Update the state of the Order object by calling Order.Cancel (reason)
- Save updated order to data warehouse
- Contact CreditCardService to return all credit card payments that have already been processed.
- Add audit record for operation
, , . , , , . , imo, , CreditCardService (Order), , , .
-, , / "". , , , . !