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