- Mastering Microservices with Java
- Sourabh Sharma
- 161字
- 2021-07-02 13:03:35
Multilayered architecture
Multilayered architecture is a common solution for DDD. It contains four layers:
- A presentation layer or user interface (UI).
- An application layer.
- A domain layer.
- An infrastructure layer
The multilayered architecture can be seen in the following diagram as follows:

You can see in the preceding diagram that only the Domain layer is responsible for the domain model, and the other layers relate 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 multilayered architecture, each layer contains its respective code. This helps to achieve loose coupling and avoids mixing code from different layers. It also helps a product/service's long-term maintainability and contributes to easy enhancements, as a change to 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 multitier architecture.