Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Confused about Bounded Contexts and SubDomains

I've read Eric Evan's book and am reading Vaughn Vernon's book now. I'm in the second chapter where he talks about subdomains and bounded context and am thoroughly confused now.

From what I was able to distill, there should be a 1:1 relationship between a BC and an SD. However, I read in other places that this isn't necessarily the case.

Can someone explain to me the relationship between a BC and SD?

like image 488
Chris Avatar asked Sep 04 '13 23:09

Chris


People also ask

Is subdomain same as bounded context?

Likewise, a subdomain is a segment of the domain, and a bounded context is a segment of the solution.

What is the relationship between a bounded context and a domain model?

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.

Can a domain have multiple bounded contexts?

Anything that shows domain concepts, relationships, rules, and so on. Since a bounded context is a boundary for a model, it could include concepts from multiple subdomains. Or a single subdomain could be modelled as multiple bounded contexts.

How do you identify bounded contexts?

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.


2 Answers

A subdomain is a part of your business. There are core domains, supporting domains and generic domains. Core domains are where the money is, supporting domains support your core business, and generic domains are the ones you need, but don't care a lot about, so you would probably buy them of the shelf. For an insurance company, the core domain is insurance, a supporting domain could be client portfolio, and a generic domain could be something like timesheets.

In general a bounded context is a boundary within which the ubiquitous language is consistent. In DDD walhalla each subdomain would live in its own bounded context. In reality however, there is legacy, there are packages that try to do everything at once... which will force all kinds of awkard relationships.

like image 100
JefClaes Avatar answered Sep 20 '22 21:09

JefClaes


I try to explain these concepts with my understanding.

In DDD, everything should be communicated under ubiquitous language so the technical team and business team can use the same terms and have same views on the problems

  • Domain in DDD represent real problem in business. Such as: E commerce is a domain, Payroll system is a domain
  • Domain is divided into many sub domains, so each sub domains focus smaller problems. Such as: E commerce has many sub domains such as: Shopping Cart, Billing, Product Catalog, Customer Information...
  • Each sub domain should have explicit responsibilities so it has a boundary to limit their functionalities, the boundary will help sub domain focus to do only 1 thing and do well. This boundary is considered as bounded context of the sub domain. The bounded context will define:
    • How many domain models needed for the sub domain?
    • Which properties needed in the each model?
    • Which functionalities needed in sub domain?

Ex: Shopping Cart sub domain needs models: Cart, Product, Customer Info... and contains functions to perform CRUD on the cart. Notes: The Product and Customer model in the Shopping Cart sub domain maybe not the same with the models in Product Catalogs and Customer Profiles sub domain, they just contain necessary properties to display on Shopping Cart.

like image 24
huaminhluan Avatar answered Sep 20 '22 21:09

huaminhluan