- Mastering Microservices with Java 9(Second Edition)
- Sourabh Sharma
- 142字
- 2021-07-02 21:54:48
Multilayered architecture
Multilayered architecture is a common solution for DDD. It contains four layers:
- Presentation layer or User Interface (UI).
- Application layer.
- Domain layer.
- Infrastructure layer.

Layered architecture
You can see here that only the Domain layer is responsible for the domain model, and others are related to other components such as UI, application logic, and so on. This layered architecture is very important. It keeps domain-related code separate from other layers.
In this multilayered architecture, each layer contains its respective code, and it helps to achieve loose coupling and avoids mixing code from different layers. It also helps the product/service's long-term maintainability and the ease of enhancements, as the change of one-layer code does not impact on other components if the change is intended for the respective layer only. Each layer can be switched with another implementation easily with multi-tier architecture.