lundi 15 novembre 2021

Service layer with Data Transfer Objects (DTO)

I'm working on a multi module maven based application based on the following modules:

  1. Model, contains all the Domain Entities
  2. Persistence, contains all the Repository (or DAO) used to access the models
  3. Service, contains all the business logic
  4. Web, contains all the controllers logic to expose rest API

The problem I'm trying to figure out is about the DTO mapping, right now the dependency are organized in a linear way:

  Model <- Persistence <- Service <- Web

Where all the DTO logic should belong? Let's say we have a method inside the service layer called

createRoom(CreateRoomDTO createRoomDTO)

in this case the CreateRoomDTO class is highly coupled with the service and web modules, but not all the DTO classes are used by the service layer (for example a PaginationFilter)

Aucun commentaire:

Enregistrer un commentaire