I always see standard Order classes implemented with a “Status” property, but I don’t feel comfortable with that. Isn’t the status a property of the fulfillment process instead of the order itself? What about orders that can be subject to different fulfillment processes?
Isn’t the status a property of the fulfillment process instead of the order itself?
It is. The Status shouldn’t belong to an Order, neither the taxes or other financial details. When modelling the Order concept it should be modelled according to what it is (domain definition) and NOT according to how it’s displayed or used by other domain processes.
A customer doesn’t order statuses, discounts or taxes. He orders products/services and attaches vouchers or coupons codes. And that’s all an Order should contain. Financial details and order fullfilment tracking are use cases of the concept NOT parts of the concept.
What a client or store employee sees is a view model which contains more than the document Order. It contains inventory data or invoice data or shipping data. So the Status is actually a concept of the Order fulfilment process (saga) which can be organized in other processes (product reservations, billing, shipping) each with their very own statuses.
OP, you’re right: Status has no place in Order’s definition. It’s just the easy way out to define an improper model mixing together different subdomains.
5
Isn’t the status a property of the fulfillment process?
No, it’s the status of an order, unless you plan on attaching a fulfillment process to the order. Normally, that’s not how it works; think of a fulfillment process as a “factory” that processes orders. A property on such a process might look like “how many orders are currently in the shipment queue?”
Your customer isn’t going to look up a fulfillment process when he wants to know what the status of his order is; he’s going to look up his order. As the programmer, you’re going to want to maintain that status in the Order record (or an OrderStatus table), not some fulfillment process (although the list of possible statuses may be influenced by that process).
7
Isn’t the status a property of the fulfillment process instead of the order itself?
Not necessarily. The fulfillment process may have a contributing status for the Order, but it’s possible that there are multiple fulfillment processes. Final status needs to remain with the Order.
What about orders that can be subject to different fulfillment processes?
Exactly. You’ve provided the counter example showing why Status should belong to the Order. Think about how you would track an order that was fulfilled through two separate processes. Work on the order could be complete in one fulfillment route but not even started within another.
4