Eric Evans, the creator of domain-driven design, proposed the following four-layer model for program development. ** ・Control layer・・・Responsible for connecting to the application with RestApi. ** **-Use case layer: In charge of business logic of the application. Domain layer methods are summarized here. ** ** ・Domain layer: A layer that describes common processing. Call in the use case layer. ** ** ・Infrastructure layer: In charge of technical logic that depends on external libraries such as email and FTP connection. It is called from layers other than the infrastructure layer. **
Domain-driven design is a concept advocated in the early 2000s. After that, domain-driven design has evolved, and new design methods that combine domain layer methods such as CQRS and event sourcing have appeared. Due to the expansion of the domain layer, the four-layer model of the architecture proposed by Eric Evans saturates, complicating the design. In this article, I’m aiming to add layer layers to the 4-tier model of the architecture to make domain-driven design more sophisticated and simple.
Add a mission layer that aggregates domain layer methods to 4-layer model
User Feature Driven Development separates the call points of domain layer methods by function (feather), and performs planning, design, coding, unit test, and release. https://www.lucidchart.com/blog/why-use-feature-driven-development
By creating a function (feather) class that aggregates methods of domain layer, it acts as an intermediary between use cases and layers and domain layer. It is suggested to follow the user’s Feature Driven Development model and add a Mission layer that aggregates domain layer methods to the 4-layer model. The following is a comparison diagram of the 4-layer model and the 5-layer model with the addition of the mission layer.
Side effects caused by adding the mission layer to the 4-layer model
** Domain layer is isolated from use case layer… Since the domain layer is isolated from the use case layer, the influence of the change of the use case layer does not spread to the domain layer. **
Providing a space to describe the logic of CQRS or event sourcing… Since CQRS or event sourcing can be described in the mission layer, the logic perspective is improved
Direction for future development of the #5 layer model The following paths are predicted as the direction of development of the 5-layer model.
**- Applying the concept of DCI architecture to the mission layer so that a wide range of requirements from the use case layer can be handled ** https://qiita.com/aLtrh3IpQEnXKN7/items/355ad12f82ac424abea3
** ・ Hierarchize the use case layer for each request level and clarify the reason for calling the mission layer method ** https://qiita.com/aLtrh3IpQEnXKN7/items/853ecb3cd109dd016476