Establishing clear interfaces
Now, we can start to decouple SalesOrderService
and WarehouseService
. To do so, we need to apply the concepts reviewed in Chapter 5, Introducing Refactoring Principles and in the previous section, such as defining clear interfaces for the services so that we can encapsulate all their work to the outside world.
We want to restructure our project to reflect the domain boundaries. To do so, we need to do the following:
Physical separation: Organize code into separate directories or namespaces per domain
Logical separation: Ensure that classes and methods within a module pertain only to that domain
To achieve this, we can start by creating a solution folder named Modules
with two subfolders named Sales
and Warehouses
in which we will create all the projects for the two bounded contexts.
In the Sales
folder, we create a project named BrewUp.Sales.Domain
, and the same in the Warehouses
folder, this time named BrewUp.Warehouses.Domain
. In...