In the BC that the Order contains, it may indeed be that Product , as part of the OrderLine , is a value object consisting of values โโsuch as ProductId , Name , etc.
The order content does not need to be aware of the nature of the product, since order lines usually only contain simple properties for values โโonly (productId / SKU, name, quantity and price per item). Therefore, Order can provide a function such as
void addOrderLine(ProductId productId, String productName, BigDecimal pricePerItem, int quantity).
This does not actually apply to Order -BC, where these values โโare for ProductId , productName , etc. come from.
However, in practice, it is probably very likely that these values โโcan be obtained from another limited context, for example, Product -BC, which is responsible for inventory management, etc.
It is generally accepted that the UI organizes these BCs:
- A user interface (such as a web store for customers) downloads products and their prices from "product-BC"
- The user places the products in the shopping cart (for simplicity, this is also an โOrder-BC"). For the UI runs commands such as
AddToShoppingBasketCommand(productId, productName, quantity, price) , which are processed by "Order" -BC. - When a user wants to place an order for the current purchase, he launches
PlaceOrderCommand . - The command handler for
PlaceOrderCommand accepts the current shopping cart and creates the corresponding Order ; all that he needs for each product is the corresponding properties of the products that were already indicated in the shopping cart (and were originally in AddToShoppingBasketCommand ). Note that he does not need to know about the Product object from Product-BC.
source share