jiminssy
jiminssy

Reputation: 2421

Implementing Bounded Context in Domain Driven Design

I recently decided to learn Domain Driven Design. I came up with a hypothetical application and tried designing the architecture for it. It is a simple Poing-Of-Sale application with bounded contexts Sales and Inventory. This is where I have two conflicting designs when implementing the code for these bounded contexts.

Design #1:

Design #2:

I am just trying to understand what Domain Driven Design approach is in such system. Thanks.

=================================

After some thought this is the added question to the original.

Let's say your business needs to do shipping. Whether it would be due to making a sale (Sales Bounded Context) or due to a warranty replacement (Support Bounded Context). What if shipping itself is complicated depending on situations. Where certain products or shipping addresses you need to make the decision to ship it yourself or via some 3rd party shipping company using a web service. Does the "shipping" deserve its own Shipping Bounded Context? Or it simply is just another domain logic embedded in the Sales Bounded Context and the Support Bounded Context? This is all within the case of simple retail store domain.

Upvotes: 3

Views: 1224

Answers (2)

varunksingh
varunksingh

Reputation: 11

Design #1 is the correct one. Inventory context should be the only one which decides and knows how to check for inventory. It could be the inventory context is checking from multiple places and those could be changing based on meta data updates as new data warehouses come online. At some point retailer might decide to have all physical shops as data warehouses as well.

Similarly shipping should be a context as well. Notes above said we should not aim for distributed system but I don't see why not if that provides agility.

Upvotes: 0

Rénald
Rénald

Reputation: 1430

My 2 cents... Design #2 seems better as Design #1 should lead you to a distributed system. You do not want a distributed system. You should not take storage or tables into account before getting the business. Just consider business, and when you get it, consider how you could be able to get your BC run in complete isolation (offline mode vs distributed mode). If data is missing, then consider using Domain Events to propagate this knowledge to your BC.

Upvotes: 2

Related Questions