Handling similarities in DDD - is Reservation and Order the same thing?

146 views
Skip to first unread message

pe...@bold7.com

unread,
Jan 6, 2021, 6:46:41 AM1/6/21
to DDD/CQRS
Hi

I have a system that includes well-known concepts of Reservations and Orders (delivery or pickup).

Orders (think of Food order - delivery or self-pickup) - they contain Merchant, User, Line Items, shipment data, it may require some additional approval and prepayment steps.
Reservation (think of reservation for a haircut) - they contain Merchant, User, Time and eventually (not required) Line Items and prepayment 

Currently, both concepts are implemented separately as independent aggregates living in separate services.
There are some new features that needs to be added to both aggregates, and I'm still thinking about the pros and cons of implementing both as one aggregate type and handling coding different behavior in saga.

In edge cases, Order feels much different than Reservation - but considering "self pick up order at specific time" and "reservation with preordered items" - they are quite similar.

If you order a pizza to eat at the restaurant at 6 pm - is that an order or reservation? 

So there are few options:

1) Treat Reservation as an Order and parametrize behavior using some flags "requiresConfirmation": true, "time" :"2021-01-01 15:30"

2) Keep both aggregates separately with their own Sagas, events. Eventually, share some parts of the code 

There is also another solution that feels technically most complicated - Implement Reservation aggregate with reservation attributes (time, confirmation status) and keep other attributes (line items, payment status) in Order aggregate that reference this reservationID - or even use same ID? 
But that feels like some direction - "I want to Reserve a table for 2 and Order a pizza".


While DDD emphasis using correct vocabulary - calling Reservation an Order may seem ugly - but does it justify duplicating so much logic?
I mean implementing both ReservationSaga and OrderSaga listening for "PaymentCompleted" and running command on aggregate etc.


Do you have experience in handling a similar cases?

Best Regards

Piotr Chruscielewski

boleck...@gmail.com

unread,
Jan 6, 2021, 12:06:46 PM1/6/21
to DDD/CQRS
The only Domain-Experts can answer this Question:  Reservation and Order the same thing?

Tomas P.

unread,
Jan 7, 2021, 12:25:30 PM1/7/21
to ddd...@googlegroups.com
Hi,

what system(s) are you building? Is it two systems or rather one system that can handle both orders and reservations or maybe even more?

How often do you change both together?

Do you have two teams managing each service separately or is it one team owning both?

For the question “is it order or reservation” ask people who are doing the business, how do they call it?


Regards
Tomas



--
You received this message because you are subscribed to the Google Groups "DDD/CQRS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dddcqrs+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dddcqrs/f63a0eab-bb81-4b4f-b861-62c1eb6c2d5dn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages