One of the core design aims is Separation of Concerns (SoC). One of the good practices, irrespective of the size of an application or microservice, is to create a layered architecture.
Each layer in a layered architecture has one concern, and it should implement it well. Layering the applications also helps in simplifying unit tests. The code in each layer can be completely unit tested by mocking out the following layer. The following figure shows some of the important layers in a typical microservice/web application:
The layers shown in the previous diagram are as follows:
- Presentation layer: In a microservice, the presentation layer is where the Rest Controllers reside. In a typical web application, this layer would also contain the view-related content--JSPs, templates, and static content. The presentation layer talks to the services layer.
- Services layer...