Tactical Domain-Driven Design: structure of domains, shared functionality structure, and high conjunction preventing

We keep talking about Domain-Driven Design. The previous article was dedicated to the strategic approach to using the ideas of DDD. Today, we’ll learn about how to use the domain-driven design method on a tactical level. For example, let's use a web application that has the following sub-domains:
Structure of a domain using layers
We hope you remember that we can use columns to subdivide domains. Also, we can slice these domains into layers of libraries which leads to row subdivisions: Slice into layers is a usual method to structurize a domain. Obviously, each layer may be composed of one or more libraries. More exotic ways are hexagonal architectures or clean architecture, but structuring in layers is more common.
Shared functionality structure.
Those functionalities and parameters that are used across the domains are called shared functionality and grouped in an additional shared column. Shared libraries are a beneficial thing. Thanks to them, you can dramatically shorten the code. Shared libraries can be used twice, thrice, and even four times. The point is that the shared column match the DDD proposed Shared Kernel. Also, it includes technical libraries to share.
High conjunction preventing.
One of the advantages of the DDD's approach is an access constraint. They define which libraries can use other libraries or depend upon them. In general, it uses a hierarchical relationship from top to bottom. It means that each layer can only communicate with underlying layers. As for cross-domain access, it is possible only in the shared area. Thus, we get a weak connection and, as a result, increased maintainability. To correspond to Open Services in DDD, developers usually seek to reduce the amount of logic in a shared area. In this case, they use this approach for developing APIs that publish building blocks for other domains. So, let's back to the diagram above: you may define the following two main characteristics of the shared part:
  • Most of the util libraries (greyed-out blocks) are placed in the shared areas. It's done primarily because of the phases they are responsible for and use across the system.
  • The general UI libraries that ensure a system-wide look and feel are also placed in the shared areas for the same reason.