I'm currently following an IT study, and we're asked to use interfaces and DTO's in a multi-layered ASP.Net Core MVC consisting of Presentation, Logic/Business, and Data Access, using dependency inversion so that both the presentation and DAL have references to the logic layer. In between the Logic and DAL, we have to use DTO's and Interfaces. I understand the concepts of both, and I know how to use them. However, we can decide for ourselves whether we want to create seperate layers for our DTO's and Interfaces, or to stick them in the logic layer. We are also asked to explain why we chose one option over the other. However, I cannot find any sources for why you would pick one over the other anywhere. So that's why I'm asking here.
So my question is: What are the advantages and disadvantages of putting your DTO's and Interfaces in a seperate layer, and what are the advantages and disadvantages of just keeping them in the logic layer?
Thanks in advance.
Advantages are:
can be used in any other layers. So each layer can expose own dto by its API, but internally it uses own classes. E.g. data layer can use internally own model clases
Person, however data layer returnsPersonDtotoBusiness Layeryou can easily reference this separate layer into other layers without forcing to introduce unnecessary dependencies. E.g., if application is using just one model from data layer, then you will have to reference this layer into presentation layer.
Disadvantages:
Advantages:
Disadvantages: