I mean - physically, in code. Organization of naming, namespaces, folders, assemblies, database/s.
How bounded contexts should interact?
For example, feel free to use classic e-commerce business domain.
To identify bounded contexts, you can use a DDD pattern called the Context Mapping pattern. With Context Mapping, you identify the various contexts in the application and their boundaries. It's common to have a different context and boundary for each small subsystem, for instance.
A bounded context is simply the boundary within a domain where a particular domain model applies. Looking at the previous diagram, we can group functionality according to whether various functions will share a single domain model. Bounded contexts are not necessarily isolated from one another.
Such a Bounded Context represents a boundary around a set of functional features (user stories / use cases). For example, everything that is related to customer management in an insurance scenario: create customer, update customer, update customer address, etc.
I'd say 'it depends'
Some times it might be enough to map your BC entities to the same database and sometimes you might have different databases for your BC's.
IMO, e-commerce might be more of a BC than a complete domain.
I've spent a bit too much time at a whole sales agent where they sold food products.
So the domain was "whole sales" and the bounded contexts was, inventory, purchase, sales, invoicing, product catalog and e-commerce (maybe I use the wrong english wording here)
Each of these BC's knew about "products" but they all had their different view of a product.
e.g. Purchase might have a product entity with vendor information, purchase price etc attached to it.
While a product in the e-commerce domain would be modelled from a customer point of view, it would have information relevant for the customer that views it, their specific price etc.
the e-commerce BC would get its product information from multiple sources; product catalog and sales. where the base information is from the product catalog and customer specific prices are from sales.
So the product repository in the e-commerce BC might do context-mapping from the other BC's (via services of some sort, most likely web or wcf in my case) to construct our e-commerce product entity)
Personally I do model this as separate assemblies, I would have an e-commerce Model and a sales model.
Most of the information in my e-commerce model would come from external sources and wouldnt be locally persistent. Only things like shopping-cart would be locally persistent since those objects are owned by the e-commerce model.
Once a customer tries to complete their purchase, I would construct a pre-order from the shopping cart and then pass that to the sales BC. Either by a direct service call or through a message queue.
So in short, I tend to build my systems around a specific BC and only interact with other BC's through services.
I know that alot of people do put their BCs in the same assemblies and use multiple BC's from the same app etc. But I just find it odd why an app for a specific purpose should know about multiple contexts. I'd rather make it know about only one context and then pass whatever data I need over to other apps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With